我是 Spring 和 hibernate 的新手,在尝试持久化事务数据时出现上述错误。请尝试解决这个问题这是我的实体:
@Entity @NamedQuery(name="Employee.findAll", query="SELECT e FROM Employee e")
public class Employee implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String city;
private String civil;
@Temporal(TemporalType.DATE)
@Column(name="dob", length=11)
private Date dob;
private String email;
private int epf;
private String fname;
private String gender;
private int landtp;
private String lname;
@Temporal(TemporalType.DATE)
@Column(name="salaryincrement", length=11)
//bi-directional many-to-one association to Designation
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="designation_id", nullable=false)
private Designation designation;
public Employee() { }
@Entity
@NamedQuery(name="Designation.findAll", query="SELECT d FROM Designation d")
public class Designation implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String type;
//bi-directional many-to-one association to Employee
@OneToMany(mappedBy="designation")//, cascade=CascadeType.ALL
private List<Employee> employees;
public Designation() {
}
这是我的实体类,实体有一个 getter 和一个 setter