[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] Help with PrimaryKey usage for legacy tables
|
I'm using EclipseLink 1.1.1 and I'm trying to map a parent-child relationship
which exists in legacy tables. I read through the documentation but I'm
still a bit confused by it.
An order's primary key is a String (order_no) that is defined as unique.
LineItems have an association to the order. The lineItem table has the
order_no field and a line_no. It is a combination of order_no and line_no
that make the PrimaryKey for the LineItem. The LineItem line_no is not
unique within the table but is only unique with the addition of the
order_no.
I've tried a few different ways of defining the @Id but nothing seems to be
quite right and the table generation is not correct. I expect the Order to
have an order_no column and the LineItem table to have a composite key of
order_no and line_no.
My objects:
Order {
@Id
@Column(name = "ORDER_NO", length = 12)
private String orderNo;
@OneToMany(fetch = FetchType.EAGER)
private java.util.List<LineItem> lineItems;
...
}
LineItem {
@ManyToOne
private Order order;
@Id
@Column(name = "LINE_NO", nullable = false)
private Integer lineNo;
}
Thanks for the help....
--
View this message in context: http://www.nabble.com/Help-with-PrimaryKey-usage-for-legacy-tables-tp25388560p25388560.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.