Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:hibernate 3.0
Mapping documents:
<?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>
<class name="EventDO" table="EVENT_LOG_HEADER_TBL">
<id name="id" column="EVENT_LOG_HEADER_ID" type="long">
<generator class="sequence">
<param name="sequence">EVENT_LOG_HEADER_TBL_SEQ</param>
</generator>
</id>
<property name="eventId">
<column name="EVENT_ID" not-null="true"/>
</property>
<property name="sessionId">
<column name="SESSION_ID" length="254" not-null="true"/>
</property>
<property name="userId">
<column name="USER_ID" length="20" not-null="true"/>
</property>
<property name="userType">
<column name="USER_TYPE" length="30" not-null="true"/>
</property>
<set name="eventDetails" cascade="all" inverse="true" lazy="true">
<key column="EVENT_LOG_HEADER_ID"/>
<one-to-many class="EventDetailDO"/>
</set>
</class>
</hibernate-mapping>
<?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>
<class name="EventDetailDO" table="EVENT_LOG_DETAIL_TBL">
<id name="id" column="ID" type="long">
<generator class="sequence">
<param name="sequence">EVENT_LOG_DETAIL_TBL_SEQ</param>
</generator>
</id>
<property name="name">
<column name="NAME" length="30" not-null="true"/>
</property>
<property name="value">
<column name="VALUE" length="40" not-null="false"/>
</property>
<many-to-one name="event" class="EventDO" column="EVENT_LOG_HEADER_ID" not-null="true"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
try {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
for(int i=0;i<al.size();i++){
session.save(al.get(i));
}
tx.commit();
}
catch (Exception he){
he.printStackTrace();
throw new RemoteException();
}
finally {
try{
HibernateUtil.closeSession();
}catch (Exception he){
he.printStackTrace();
throw new RemoteException();
}
}
}
Classes use for mapping
public class EventDO implements Serializable{
private long id;
private long eventId;
private String userId;
private String userType;
private String sessionId;
private Set eventDetails;
public EventDO() {
}
public long getId() {
return id;
}
public void setId(long argId) {
this.id = argId;
}
public long getEventId() {
return eventId;
}
public void setEventId(long argEventId) {
this.eventId = argEventId;
}
public String getUserId() {
return userId;
}
public void setUserId(String argUserId) {
this.userId = argUserId;
}
public String getUserType() {
return userType;
}
public void setUserType(String argUserType) {
this.userType = argUserType;
}
public Set getEventDetails() {
return eventDetails;
}
public void setEventDetails(Set argEventDetails) {
this.eventDetails = argEventDetails;
}
public String getSessionId() {
return sessionId;
}
public void setSessionId(String argSessionId) {
this.sessionId = argSessionId;
}
}
public class EventDetailDO implements Serializable{
private long id;
private EventDO event;
private String name;
private String value;
public EventDetailDO() {
}
public long getId() {
return id;
}
public void setId(long argId) {
this.id = argId;
}
public EventDO getEvent() {
return event;
}
public void setEvent(EventDO argEvent) {
this.event = argEvent;
}
public String getName() {
return name;
}
public void setName(String argName) {
this.name = argName;
}
public String getValue() {
return value;
}
public void setValue(String argValue) {
this.value = argValue;
}
Full stack trace of any exception that occurs:
[[INFO] Environment - Hibernate 3.0.5
[INFO] Environment - hibernate.properties not found
[INFO] Environment - using CGLIB reflection optimizer
[INFO] Environment - JVM does not support Statement.getGeneratedKeys()
[INFO] Environment - JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled
[INFO] Environment - using workaround for JVM bug in java.sql.Timestamp
[INFO] Environment - using pre JDK 1.4 java.sql.Timestamp handling
[INFO] Configuration - configuring from resource: /hibernate.cfg.xml
[INFO] Configuration - Configuration resource: /hibernate.cfg.xml
[INFO] Configuration - Mapping resource: EventHeader.hbm.xml
[INFO] HbmBinder - Mapping class: EventDO -> EVENT_LOG_HEADER_TBL
[INFO] Configuration - Mapping resource: EventDetail.hbm.xml
[INFO] HbmBinder - Mapping class: EventDetailDO -> EVENT_LOG_DETAIL_TBL
[INFO] Configuration - Configured SessionFactory: hibernate_SessionFactory
[INFO] Configuration - processing extends queue
[INFO] Configuration - processing collection mappings
[INFO] HbmBinder - Mapping collection: EventDO.eventDetails -> EVENT_LOG_DETAIL_TBL
[INFO] Configuration - processing association property references
[INFO] Configuration - processing foreign key constraints
[INFO] NamingHelper - JNDI InitialContext properties:{}
[INFO] DatasourceConnectionProvider - Using datasource: weblogic.jdbc.jts.dataSyncPool
[INFO] SettingsFactory - RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
[INFO] SettingsFactory - JDBC driver: Oracle JDBC driver, version: 9.2.0.2.0
[INFO] Dialect - Using dialect: org.hibernate.dialect.Oracle9Dialect
[INFO] TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JTATransactionFactory
[INFO] NamingHelper - JNDI InitialContext properties:{}
[INFO] TransactionManagerLookupFactory - instantiating TransactionManagerLookup: org.hibernate.transaction.WeblogicTransactionManagerLookup
[INFO] TransactionManagerLookupFactory - instantiated TransactionManagerLookup
[INFO] TransactionManagerLookupFactory - instantiating TransactionManagerLookup: org.hibernate.transaction.WeblogicTransactionManagerLookup
[INFO] TransactionManagerLookupFactory - instantiated TransactionManagerLookup
[INFO] SettingsFactory - Automatic flush during beforeCompletion(): disabled
[INFO] SettingsFactory - Automatic session close at end of transaction: disabled
[INFO] SettingsFactory - JDBC batch size: 15
[INFO] SettingsFactory - JDBC batch updates for versioned data: disabled
[INFO] SettingsFactory - Scrollable result sets: enabled
[INFO] SettingsFactory - JDBC3 getGeneratedKeys(): disabled
[INFO] SettingsFactory - Connection release mode: null
[INFO] SettingsFactory - Default batch fetch size: 1
[INFO] SettingsFactory - Generate SQL with comments: disabled
[INFO] SettingsFactory - Order SQL updates by primary key: disabled
[INFO] SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[INFO] ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
[INFO] SettingsFactory - Query language substitutions: {}
[INFO] SettingsFactory - Second-level cache: enabled
[INFO] SettingsFactory - Query cache: disabled
[INFO] SettingsFactory - Cache provider: org.hibernate.cache.EhCacheProvider
[INFO] SettingsFactory - Optimize cache for minimal puts: disabled
[INFO] SettingsFactory - Structured second-level cache entries: disabled
[INFO] SettingsFactory - Echoing all SQL to stdout
[INFO] SettingsFactory - Statistics: disabled
[INFO] SettingsFactory - Deleted entity synthetic identifier rollback: disabled
[INFO] SettingsFactory - Default entity-mode: pojo
[INFO] SessionFactoryImpl - building session factory
[WARN] Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Audit_Reports/cpDomain/lib/hibernate/ehcache-1.1.jar!/e
[INFO] SessionFactoryObjectFactory - Factory name: hibernate_SessionFactory
[INFO] NamingHelper - JNDI InitialContext properties:{}
[INFO] SessionFactoryObjectFactory - Bound factory to JNDI name: hibernate_SessionFactory
[WARN] SessionFactoryObjectFactory - InitialContext did not implement EventContext
[INFO] NamingHelper - JNDI InitialContext properties:{}
[INFO] SessionFactoryImpl - Checking 0 named queries
Session created org.hibernate.impl.SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]] ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRe
Hibernate: select EVENT_LOG_HEADER_TBL_SEQ.nextval from dual
Hibernate: select EVENT_LOG_DETAIL_TBL_SEQ.nextval from dual
org.hibernate.PropertyValueException: not-null property references a null or transient value: EventDetailDO.event
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:236)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.engine.Cascades$5.cascade(Cascades.java:154)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:771)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:895)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascade(Cascades.java:847)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:363)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
Name and version of the database you are using:
oracle 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: