求解cascade和mappedby的用法

谁能讲一下ejb3中7种关系中的cascade 和mappedby的用法,前一段时间看了两本书,居然讲的不一样,谢了!!
In Customer class:

@OneToMany(cascade=ALL, mappedBy="customer")
public Set getOrders() { return orders; }

In Order class:

@ManyToOne
@JoinColumn(name="CUST_ID", nullable=false)
public Customer getCustomer() { return customer; }


In Customer class:

@OneToMany(cascade=ALL, mappedBy="customer")
public Set getOrders() { return orders; }

In Order class:

@ManyToOne
@JoinColumn(name=
"CUST_ID", nullable=false)
public Customer getCustomer() { return customer; }



mappedBy="customer"
说明在两个关联的实体Bean中,orders这一端是关系的拥有者,Orders一方的表中生成到关联类的外键
且mappedBy只有在双向关联时,才会使用这个属性
cascade=ALL
说明,当Orders做CRUD操作时,Customer都会进行相应操作

[该贴被xinying_ge于2008-04-22 17:04修改过]
[该贴被xinying_ge于2008-04-24 13:15修改过]