求救:加了前缀属性就无法运行
上面是我的代码
加了前缀属性就无法运行,注释掉就正常
我是跟着老师的视频走的,其他代码一致
求大神拯救
ps:加了前缀属性后
最后给一个
ERROR: HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: null id in pojo.Student entry (don't flush the Session after an exception occurs)
啥意思?
我手动设置id=1不行,id为null不行,不设置id也不行
不要前缀属性就咋都行(设置id没有用,自动增长的)
package pojo; import java.util.Date; public class Student implements java.io.Serializable { // Fields private int id; private String name; private String gender; private Date birthday; private String address; // Constructors /** default constructor */ public Student() { } /** full constructor */ public Student(String name, String gender, Date birthday, String address) { this.name = name; this.gender = gender; this.birthday = birthday; this.address = address; } // Property accessors public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getGender() { return this.gender; } public void setGender(String gender) { this.gender = gender; } public Date getBirthday() { return this.birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } public String getAddress() { return this.address; } public void setAddress(String address) { this.address = address; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return "Student [id=" + id + ", name=" + name + ", gender=" + gender + ", birthday=" + birthday + ", address=" + address + "]"; } } 上面是类 下面是映射 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> <hibernate-mapping> <class name="pojo.Student" table="student" catalog="xiele007"> <id name="id" type="java.lang.Integer"> <column name="id" /> <generator class="native" /> </id> <property name="name" type="java.lang.String"> <column name="name" length="16" /> </property> <property name="gender" type="java.lang.String"> <column name="gender" length="32" /> </property> <property name="birthday" type="java.util.Date"> <column name="birthday" length="10" /> </property> <property name="address" type="java.lang.String"> <column name="address" /> </property> </class> </hibernate-mapping>