O'Reilly logo

Java EE 6 Development with NetBeans 7 by David R. Heffelfinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Entity Relationships

There are several annotations we can use in JPA entities to define relationships between them. In our Customer entity shown above, we can see that the wizard detected several one to many relationships in the CUSTOMER table, and automatically added the @OneToMany annotation to define these relationships in our entity. Notice that each field annotated with the @OneToMany annotation is of type java.util.Collection, the Customer is the "one" side of the relationship, since a customer can have many orders, many addresses (street, mail, etc), or many telephone numbers (home, work, cell, etc.). Notice that the wizard uses generics to specify the type of objects we can add to each collection. Objects in these collections are the JPA ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required