Single-valued entity associations user … This mapping seems (Web hosting domain names)

Single-valued entity associations
user
This mapping seems strange at first. Read it as follows: When an Address is saved, the primary key value is taken from the user property. The user property is a reference to a User object; hence, the primary key value that is inserted is the same as the primary key value of that instance. Look at the table structure in figure 7.2. Figure 7.2 The USERSand ADDRESStables have the same primary keys. The code to save both objects now has to consider the bidirectional relationship, and it finally works: User newUser = new User(); Address shippingAddress = new Address(); newUser.setShippingAddress(shippingAddress); shippingAddress.setUser(newUser); // Bidirectional session.save(newUser); Let s do the same with annotations. Shared primary key with annotations JPA supports one-to-one entity associations with the @OneToOne annotation. To map the association of shippingAddress in the User class as a shared primary key association, you also need the @PrimaryKeyJoinColumn annotation: @OneToOne @PrimaryKeyJoinColumn private Address shippingAddress; This is all that is needed to create a unidirectional one-to-one association on a shared primary key. Note that you need @PrimaryKeyJoinColumns (plural)
Check Tomcat Web Hosting services for best quality webspace to host your web application.