Now when i attempt to Save GroupMember object by filling all member variable, Hibernate only does insertion for 3 column, one column fkgroup is not getting inserted.
insert into GroupMember (priority, gmid, cId) values (?, ?, ?)
I'm unable to save fkgroup column of GroupMember table, get following exception
SEVERE: SQL Anywhere Error -194: No primary key value for foreign key 'group' in table 'GroupMember' org.hibernate.exception.ConstraintViolationException: could not insert: [my.test.pkg.GroupMember]
Then i realized that insert="false" is set many-to-one relation which is causing issue for fkgroup not to be inserted. Setting insert="true" here gives exception
org.hibernate.MappingException: Repeated column in mapping for entity: my.test.pkg.GroupMember column: cId (should be mapped with insert="false" update="false")
For now, i have no idea how can insert GroupMember with fkgroup foreign key.
I have checked forum, but couldn't find any solution.
Any help on how can i insert/save GroupMember object ??
In my case i have Composite Primary key and foreign key which is also composite key. Now one of the column is same
i.e. Table Group has composite Id PRIMARY KEY(gId, cId) [ Where cId is primary key of other table ]
Now Table GroupMember has composite primary key PRIMARY KEY(gmid, cId ) [ Where cId is primary key of other table ].
GroupMember also has foreign key fkgroup REFERENCES Group(gid, cId) (which is composite key as mentioned above]
Now, when i attemt to save GroupMember instance, foreign key (fkgroup) is not inserted. In many-to-one relationship i cannot set insert=true because cId is part of primary key for both GroupMember and Group Table.
How do i persist column fkgroup of GroupMemeber table?