SSH框架中HIbernate能查询删除更新,不能插入,这是因为什么??
我表字段只有两个,而且插入前控制台输出时,对象的值都能输出,不存在插入值为空,报的错为:
could not insert: [ssh.entity.Users]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [ssh.entity.Users]<hibernate-mapping>
<class name="ssh.entity.Users" table="Users" schema="dbo" catalog="epet">
<id name="userid" type="java.lang.String">
<column name="userid" length="50" />
<generator class="native"></generator>
</id>
<property name="password" type="java.lang.String">
<column name="password" length="50" not-null="true" />
</property>
</class>
</hibernate-mapping>
我表字段只有两个,而且插入前控制台输出时,对象的值都能输出,不存在插入值为空,报的错为:
could not insert: [ssh.entity.Users]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [ssh.entity.Users]<hibernate-mapping>
<class name="ssh.entity.Users" table="Users" schema="dbo" catalog="epet">
<id name="userid" type="java.lang.String">
<column name="userid" length="50" />
<generator class="native"></generator>
</id>
<property name="password" type="java.lang.String">
<column name="password" length="50" not-null="true" />
</property>
</class>
</hibernate-mapping>
约束冲突,我怀疑是因为你数据库底层设置的主键策略跟你用的主键策略冲突造成的。
检查一下你的数据库设置。
谢谢,本人是新手!