Home
Completing the entity classes
The generated entities are missing the table mapping, such as ITSO.CUSTOMER. Without explicit mapping, default table names are assumed, and such default names have the current user ID as schema name.
For the Account entity we add the @Table annotation to the entity and the relationship: @Table (schema="ITSO", name="ACCOUNT")
public class Account implements Serializable {
......
@ManyToMany
@JoinTable(name="ACCOUNT_CUSTOMER", schema="ITSO",
joinColumns=@JoinColumn(name="ACCOUNT_ID"),
inverseJoinColumns=@JoinColumn(name="CUSTOMER_SSN"))
private Set<Customer> customerCollection;
For the Customer entity we add the @Table annotation: @Table (schema="ITSO", name="CUSTOMER")
public class Customer implements Serializable {
For the Transaction entity we add the schema to the @Table annotation, and the @ForeignKey annotation to the relationship with Account: @Table(schema="ITSO", name="TRANSACT")
public class Transaction implements Serializable {
......
@ManyToOne
@ForeignKey
private Account account;
Resolve the missing import statement by selecting Source Æ Organize Imports or press Ctrl+Shift+O.
ibm.com/redbooks