项目中使用spring3.0.3+hibernate3.3.5final,出现以下异常:
一对多使用注解如下:
解决办法:降低hibernate版本到3.3.2,问题解决!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
一对多使用注解如下:
@Entity(name = "room")
public class Room {
@Id @Column(length=50)
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid",strategy="uuid")
private String room_id;
@Column(length = 20)
private String room_type;
@Column(length = 30)
private String room_ip;
private Integer room_port;
@Column(length = 100)
private String room_name;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "room")
private List<RoomPartInfo> partInfos;
。。。
}
@Entity(name = "RoomPartInfo")
public class RoomPartInfo {
@Id
@Column(length = 50)
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
private String part_id;
@Column(length = 30)
private String part_type;
@Column(length = 100)
private String part_name;
@ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST,
CascadeType.PERSIST })
@JoinColumn(name = "room_id", updatable = false)
private Room room;
private Byte part_addr;
。。。
}
解决办法:降低hibernate版本到3.3.2,问题解决!