|
|
|
Re: ManyToMany mapping created when no mapping is specified [message #1037892 is a reply to message #1034693] |
Wed, 10 April 2013 06:13 |
Saravanan Subiramaniam Messages: 10 Registered: April 2013 |
Junior Member |
|
|
Hi Chris,
What do you mean by replace the default mapping with OneToManyMapping in the session customizer, remove the mapping and add?
classDescriptor.getMappings().remove(classDescriptor.getMappingForAttributeName("childList"));
classDescriptor.addMapping(newOneToManyMapping);
Also, I tried marking the attribute with @Transient and creating OneToManyMapping (as given below).
@Transient
private List<Child> childList;
And in the customizer,
OneToManyMapping oneToManyMapping = new OneToManyMapping();
oneToManyMapping.setAttributeName("childList");
oneToManyMapping.useTransparentList();
oneToManyMapping.privateOwnedRelationship();
oneToManyMapping.setCascadeAll(TRUE);
oneToManyMapping.setReferenceClass(Parent.class);
oneToManyMapping.addTargetForeignKeyFieldName("PARENT_ID", "ID");
classDescriptor.addMapping(oneToManyMapping);
When I persist the parent along with childList, the childList is not persisted. Also when I query the parent and then invoke getChildList(), no sql stmt is fired. Looks like the mapping is incorrect. Could you please explain what is missing here? (Note that it works when I don't mark the attribute @Transient and replace the ManyToManyMapping with OneToManyMapping).
[Updated on: Wed, 10 April 2013 18:01] Report message to a moderator
|
|
|
|
Re: ManyToMany mapping created when no mapping is specified [message #1042459 is a reply to message #1042450] |
Tue, 16 April 2013 13:14 |
Saravanan Subiramaniam Messages: 10 Registered: April 2013 |
Junior Member |
|
|
Hi James,
Removing @Transient and remove existing mapping and add new mapping in the customizer works. Just wondering why it didn't work when the attribute is marked with @Transient (also tried by disabling eclipselink.weaving.internal). Just before the parent entity is persisted, if I get the server session and see the mapping for the child attribute, it is present (and with valid reference class). Is there a way to debug what/where the problem is?
Thanks,
Saravanan.
[Updated on: Tue, 16 April 2013 13:45] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04255 seconds