Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.stone.prop.bean">
<class name="BusinessProperties" table="BUSINESS_PROPERTIES">
<id
column="BP_ID"
name="id"
type="java.lang.Long"
>
<generator class="native" />
</id>
<property
column="PROP_KEY"
length="100"
name="propKey"
not-null="false"
type="string"
/>
<property
column="DISCRIBE"
length="200"
name="discribe"
not-null="false"
type="string"
/>
<property
column="ORG_CODE"
length="20"
name="orgCode"
not-null="false"
type="string"
/>
<property
column="PROP_VALUE"
length="200"
name="propValue"
not-null="false"
type="string"
/>
<property
column="CREATE_DATE"
length="23"
name="createDate"
not-null="false"
type="timestamp"
/>
<property
column="VALID_DATE"
length="23"
name="validDate"
not-null="false"
type="timestamp"
/>
<property
column="INVALID_DATE"
length="23"
name="invalidDate"
not-null="false"
type="timestamp"
/>
<property
column="PROP_GROUP"
length="10"
name="propGroup"
not-null="false"
type="string"
/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Full stack trace of any exception that occurs:Code:
org.hibernate.exception.ConstraintViolationException: could not insert: [com.stone.prop.bean.BusinessProperties]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1986)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2405)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:37)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:269)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:544)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:533)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:529)
at com.stone.prop.dao.base.BaseRootDAO.save(BaseRootDAO.java:627)
at com.stone.prop.dao.base.BaseRootDAO.save(BaseRootDAO.java:608)
at com.stone.prop.dao.base.BaseBusinessPropertiesDAO.save(BaseBusinessPropertiesDAO.java:76)
at com.stone.prop.BusinessPropertiesManager.save(BusinessPropertiesManager.java:137)
at com.stone.prop.BusinessPropertiesManagerTest.main(BusinessPropertiesManagerTest.java:16)
Caused by: java.sql.SQLException: could not insert NULL value to 'BP_ID',in table 'oa_prop.dbo.BUSINESS_PROPERTIES';
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:364)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2754)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2195)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:620)
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:483)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:445)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:402)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1968)
... 19 more
Name and version of the database you are using:Code:
MS SQL SERVICE 2000
The generated SQL (show_sql=true):Code:
Hibernate: select this_.BP_ID as BP1_0_0_, this_.PROP_KEY as PROP2_0_0_, this_.DISCRIBE as DISCRIBE0_0_, this_.ORG_CODE as ORG4_0_0_, this_.PROP_VALUE as PROP5_0_0_, this_.CREATE_DATE as CREATE6_0_0_, this_.VALID_DATE as VALID7_0_0_, this_.INVALID_DATE as INVALID8_0_0_, this_.PROP_GROUP as PROP9_0_0_ from BUSINESS_PROPERTIES this_
Hibernate: insert into BUSINESS_PROPERTIES (PROP_KEY, DISCRIBE, ORG_CODE, PROP_VALUE, CREATE_DATE, VALID_DATE, INVALID_DATE, PROP_GROUP) values (?, ?, ?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt: