I have 3 objects, in a hierarchical relationship; bascially a two-deep
one-to-many association. Group -> Display -> Component, where a Group has a
one-to-many with Display, and Display has a one-to-many with Component. What's
happening is when I do an em.find(), with the ID of a Group, the resulting
Group comes back with multiple Displays, where there should only be one
(according to the database). The pattern is, if there are 3 Components, I get
three Displays back (with identical IDs). If there are 5 Components, I get 5
Displays back in the Group, and so on.
The annotations are shown below. I've played with changing the FetchTypes, but
the behavior is always the same. Also, as a workaround, I changed the Lists to
Sets, so that no duplicates could be added, and that fixed it, but I don't
think that should be necessary.
Is this a known bug?
@Entity
public class Group {
...
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy =
"group")
public List getDisplays() {...}
}
@Entity
public class Display {
...
@JoinColumn(name="group_id")
@ManyToOne(targetEntity = Group.class)
public Group getGroup() {...}
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy =
"display")
public List getComponents() {...}
}
@Entity
public class Component {
...
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "display_id")
public Child getDisplay() {...}
}
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3912483#3912483
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3912483
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user