0

一位客户有多个地址,但只有一个当前地址。

因此,在我的 Oracle 中,我将拥有以下表格:

CUSTOMER
CUSTOMER_ID
NAME
CURRENT_ADDRESS

ADDRESS
ADDRESS_ID
CUSTOMER_ID
ADDRESS_DETAILS

我似乎无法映射出我的休眠关系以能够设置其当前地址并有一个列表来查找其所有以前的地址

我需要弱关系来表示它的当前地址吗?

IE

CURRENT_ADDRESS
CUSTOMER_ID
ADDRESS_ID

我确信这是一个以前已经解决的常见问题。

4

1 回答 1

0
  1. remove the current_address pointer in the customer table.
    1. add an indicator in the address table : IS_CURRENT.
    2. create a view that will select only the IS_CURRENT = TRUE addresses.
    3. connect this view to the customer's entity using @OneToOne annotation.

you can find other solutions including mine in this question

hope it helped you :)

于 2013-08-15T11:24:03.857 回答