I have an object with several @onetomany relationships, and I need to request the properties in the parent as well as the properties of the child elements. I can not do it.
For example, I need a query that allows me to see the objects of the parent, where the parent name is "John" and the child's favorite color is blue. Hope this makes sense. The reason for the complication is that the children are on the list, not the @onetoone relationship.
PARENT: @Entity @Table(name="Parent") public class Parent { @Id @Column(name="ID") @GeneratedValue(strategy=GenerationType.AUTO, generator="parent_gen") @SequenceGenerator(name="parent_gen", sequenceName="PARENT_SEQUENCE") private int parentID; @Column(name="name") private String name; @OneToMany(cascade=CascadeType.ALL) @OrderBy("name ASC") @JoinTable(name = "parent_to_child") private List<Child> childList; // and so forth Child @Entity @Table(name="Child") public class Child{ @Id @Column(name="ID") @GeneratedValue(strategy=GenerationType.AUTO, generator="child_gen") @SequenceGenerator(name="child_gen", sequenceName="CHILD_SEQUENCE") private int childID; @Column(name="favoriteColor") private String favoriteColor; // and so forth
Jorge source share