日期:2014-05-20 浏览次数:20848 次
public class A implements Serializable { private static final long serialVersionUID = -1317006094950982121L; //其余属性及get、set方法省略 @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @OneToMany (cascade = {CascadeType.REFRESH, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE}, fetch=FetchType.LAZY) private List<B> b = new ArrayList<B>(); } public class B implements Serializable { private static final long serialVersionUID = -1317006094950982121L; //其余属性及get、set方法省略 @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; //注:A中单向一对多配置,B中不配置A属性 }