I have a simple JPA project running (with IBM RAD 7.5 on WebSphere 7).
I have a Customer that has many Orders. Looks like this …
@Entity
public class Customer /* in table CC_CUSTOMER */
@Id
BigDecimal customerId;
@OneToMany(fetch=FetchType.EAGER)
private List<Order> orderList;
…
@Entity
public class Order /* in table CC_ORDER */
@Id
BigDecimal orderId;
Customer customer;
The problem I have is when I try to retrieve a Customer, I get an error because the SQL that’s being generated by JPA contains a select for a non-existant table called: CC_CUSTOMER_CC_ORDER
What am I doing wrong?
Thanks!
Rob
You have a missing @ManyToOne annotation at Customer customer; and mappedBy=”customer” at @OneToMany annotation
Customer entity
Order entity
Because of that JPA thinks that your relationship is unidirectional and this is solved by join table named CC_CUSTOMER_CC_ORDER. If you let your provider generate the schema the table should be generated.