【发布时间】:2011-08-14 13:07:50
【问题描述】:
我正在使用this 链接制作示例程序 我在 sqlserver 中有以下表格:
`CREATE TABLE Student2(
STUDENT_ID int NOT NULL,
LastName varchar(255) NOT NULL,
STUDENT_NAME varchar(255),
STUDENT_ADDRESS int,
UNIQUE (STUDENT_ADDRESS))
CREATE TABLE Address2(
ADDRESS_ID int NOT NULL,
LastName varchar(255) NOT NULL,
ADDRESS_STREET varchar(255),
ADDRESS_CITY varchar(255),
ADDRESS_STATE varchar(255),
ADDRESS_ZIPCODE varchar(255))
我在 Student.hbm.xml 中输入了studentId int:
<id name="studentId" type="int" column="STUDENT_ID">
<generator class="native" />
</id>
我在 Address.hbm.xml 中取了 addressId type int:
<id name="addressId" type="int" column="ADDRESS_ID">
<generator class="native" />
</id>
我面临以下异常:
org.hibernate.exception.ConstraintViolationException: could not insert: [com.vaannila.student.Address]`
exception:`org.hibernate.exception.ConstraintViolationException: could not insert: [com.vaannila.student.Address]
Caused by: java.sql.SQLException: Cannot insert the value NULL into column 'ADDRESS_ID', table 'sample.dbo.Address2'; column does not allow nulls. INSERT fails.
请帮忙。
【问题讨论】:
标签: hibernate hibernate-mapping