org.springframework.dao.DataIntegrityViolationException

student.hbm.xml
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="com.test.bean">
<class name="Student" table="student">
	
	<id name="sid" column="sid" type="java.lang.Integer" length="11">
		<generator class="assigned"/>
	</id>
	
	<property name="sname" type="java.lang.String" column="sname" not-null="true" length="20"></property>
	<property name="major" type="java.lang.String" column="major" not-null="true" length="20"></property>
	<property name="birthday" type="java.util.Date" column="birthday" not-null="true"></property>
	<property name="score" type="java.lang.Double" column="score" not-null="false"></property>
</class>
</hibernate-mapping>

============================================================================
解决办法:not-null="false"

你可能感兴趣的:(DAO,Hibernate,.net,xml)