How to implement one-to-many and one-to-one (some code sample)? Is it possible to integrate referenced integrity (delete records when the master record is deleted or updated)?
Thank you!
Community moderators have prevented the ability to post new answers.
1. Relationships
Its done with annotations, here is a one-to-one excerpt from JEMH, in my ConfigEntity I have:
@OneToOne
public JEMHPGPConfigEntity getGPGConfiguration();
And likewise, a one-to-many:
Hello Andy,
Can i know how can i insert data in the child table as,
say if i have a table as myTable and the other table as childTable,
now if i want to insert data into childTable how can i achieve that ,child table is one which is referering the primary key of the myTable., i am not able to get it ,can you please share a code snippet.
Thanks and regards,
--Moiz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you have to add a setter on the child to take the type of the parent, eg
public void setParent(ParentType pt);
then the @OneToMany or @OneToOne will automatically resolve, so that (from the parent) then resolves:
@OneToMany
public ChildType[] getChildren();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks andy for your kind help,
but i got an error as,
org.postgresql.util.PSQLException: ERROR: relation "public.AO_CCE27F_XYZ_ID_seq" does not exist
am i missing something..
--Moiz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
possibly database permissions required for the connecting user in order to create those sequences. assuming all entities are (a) annotated as such and (b) referred in atlassian-plugin.xml
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yeah i was not able to create via plugin but when i manually created above specified table the error was resolved,
in my atlassian-plugin.xml do i need to add both entities as
<ao key="ao-module-main"> <description>The module configuring the Active Objects service used by this plugin</description> <entity>com.auto.actObj.MainObject</entity> </ao> <ao key="ao-Assigneemodule"> <description>The module configuring the Active Objects service used by this plugin</description> <entity>com.auto.actObj.XYZ</entity> </ao>
but when i do so i got another error as,
com.atlassian.plugin.PluginException: com.atlassian.activeobjects.osgi.TooManyServicesFoundException: Was expecting one service reference for interface <com.atlassian.activeobjects.config.ActiveObjectsConfiguration> and filter <(com.atlassian.plugin.key=xyz.XYZ)>. Got 2 !
when i comment the second module i am able to recompile but not able to create both tables.
--Moiz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should only have one <ao></ao> with all entities therein. If you have further questions, please post a new question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi andy,
Thanks for your support.this really solved my problem.
--Moiz.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.