Professional web hosting - CHAPTER 8 Legacy databases and custom SQL Each
CHAPTER 8 Legacy databases and custom SQL Each secondary table needs a name and a join condition. In this example, a foreign key column references the primary key column of the USERS table, just like earlier in the XML mapping. (This is the default join condition, so you can only declare the secondary table name, and nothing else). You can probably see that the syntax of annotations is starting to become an issue and code is more difficult to read. The good news is that you won t have to use secondary tables often. The actual component property, billingAddress, is mapped as a regular @Embedded class, just like a regular component. However, you need to override each component property column and assign it to the secondary table, in the User class: @Embedded @AttributeOverrides( { @AttributeOverride( name = “street”, column = @Column(name=”STREET”, table = “BILLING_ADDRESS”) ), @AttributeOverride( name = “zipcode”, column = @Column(name=”ZIPCODE”, table = “BILLING_ADDRESS”) ), @AttributeOverride( name = “city”, column = @Column(name=”CITY”, table = “BILLING_ADDRESS”) ) }) private Address billingAddress; This is no longer easily readable, but it s the price you pay for mapping flexibility with declarative metadata in annotations. Or, you can use a JPA XML descriptor:
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.