Hibernate version: 3.0.5
Mapping documents:
Code:
<?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">
<!--
Auto-generated mapping file from
the jABC-DB-schema plugin.
-->
<hibernate-mapping package="db" schema="adr">
<class name="Person" table="`person`">
<id name="Pid" type="int">
<column name="`pid`"/>
<generator class="assigned"/>
</id>
<property name="Name" type="java.lang.String">
<column name="`name`" length="50" not-null="false"/>
</property>
<property name="Adresse" type="java.lang.String">
<column name="`adresse`" length="200" not-null="false"/>
</property>
<set name="Fk_person" inverse="true" lazy="false">
<key property-ref="propfk_person">
<column name="`personid`" not-null="false"/>
</key>
<one-to-many class="Email"/>
</set>
<properties name="propfk_person" unique="true">
<property name="Pid" insert="false" update="false"/>
</properties>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
private void butTxtAddressActionPerformed(ActionEvent evt) {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
Person pers = personen.get(lstPerson.getSelectedIndex());
session.refresh(pers);
pers.setAdresse(txtAddress.getText());
session.flush();
tx.commit();
HibernateUtil.closeSession();
}
Full stack trace of any exception that occurs:Code:
Exception in thread "AWT-EventQueue-0" org.hibernate.PropertyAccessException: exception getting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of db.Person.?
at org.hibernate.tuple.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:42)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:257)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:158)
at org.hibernate.engine.CollectionKey.getHashCode(CollectionKey.java:45)
at org.hibernate.engine.CollectionKey.<init>(CollectionKey.java:33)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:311)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:726)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:320)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at EMailDB.butTxtAddressActionPerformed(EMailDB.java:519)
at EMailDB.access$6(EMailDB.java:510)
at EMailDB$7.actionPerformed(EMailDB.java:502)
at javax.swing.JTextField.fireActionPerformed(Unknown Source)
at javax.swing.JTextField.postActionEvent(Unknown Source)
at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at db.Person$$BulkBeanByCGLIB$$dbd7fe8f.getPropertyValues(<generated>)
at net.sf.cglib.beans.BulkBean.getPropertyValues(BulkBean.java:48)
at org.hibernate.tuple.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:39)
... 39 more
with hibernate.cglib.use_reflection_optimizer=falseCode:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:105)
at org.hibernate.tuple.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:61)
at org.hibernate.tuple.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:67)
at org.hibernate.tuple.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:50)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:257)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:158)
at org.hibernate.engine.CollectionKey.getHashCode(CollectionKey.java:45)
at org.hibernate.engine.CollectionKey.<init>(CollectionKey.java:33)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:311)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:726)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:320)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at EMailDB.butTxtAddressActionPerformed(EMailDB.java:519)
at EMailDB.access$6(EMailDB.java:510)
at EMailDB$7.actionPerformed(EMailDB.java:502)
at javax.swing.JTextField.fireActionPerformed(Unknown Source)
at javax.swing.JTextField.postActionEvent(Unknown Source)
at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Name and version of the database you are using:PostgreSQL 8.0
Debug level Hibernate log excerpt:Code:
Start
25188 [AWT-EventQueue-0] DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 4638796959870976
25188 [AWT-EventQueue-0] DEBUG org.hibernate.transaction.JDBCTransaction - begin
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - opening JDBC connection
25188 [AWT-EventQueue-0] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
25188 [AWT-EventQueue-0] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
25188 [AWT-EventQueue-0] DEBUG org.hibernate.transaction.JDBCTransaction - current autocommit status: false
25188 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.DefaultRefreshEventListener - refreshing transient [db.Person#7]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Materializing entity: [db.Person#7]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - loading entity: [db.Person#7]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
25188 [AWT-EventQueue-0] DEBUG org.hibernate.SQL - select person0_."pid" as pid1_0_, person0_."name" as name2_0_0_, person0_."adresse" as adresse3_0_0_, person0_.Pid as Pid0_0_ from adr."person" person0_ where person0_."pid"=?
Hibernate: select person0_."pid" as pid1_0_, person0_."name" as name2_0_0_, person0_."adresse" as adresse3_0_0_, person0_.Pid as Pid0_0_ from adr."person" person0_ where person0_."pid"=?
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
25188 [AWT-EventQueue-0] DEBUG org.hibernate.type.IntegerType - binding '7' to parameter: 1
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - processing result set
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - result set row: 0
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - result row: EntityKey[db.Person#7]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [db.Person#7]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Hydrating entity: [db.Person#7]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.type.StringType - returning 'Sven' as column: name2_0_0_
25188 [AWT-EventQueue-0] DEBUG org.hibernate.type.StringType - returning null as column: adresse3_0_0_
25188 [AWT-EventQueue-0] DEBUG org.hibernate.type.IntegerType - returning '7' as column: Pid0_0_
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - done processing result set (1 rows)
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - total objects hydrated: 1
25188 [AWT-EventQueue-0] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [db.Person#7]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.engine.CollectionLoadContext - creating collection wrapper:[db.Person.Fk_person#component[Pid]{Pid=7}]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [db.Person#7]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.engine.PersistenceContext - initializing non-lazy collections
25188 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.DefaultInitializeCollectionEventListener - initializing collection [db.Person.Fk_person#component[Pid]{Pid=7}]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.DefaultInitializeCollectionEventListener - checking second-level cache
25188 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.DefaultInitializeCollectionEventListener - collection not cached
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - loading collection: [db.Person.Fk_person#component[Pid]{Pid=7}]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
25188 [AWT-EventQueue-0] DEBUG org.hibernate.SQL - select fk_person0_."personid" as personid2___, fk_person0_."email" as email1___, fk_person0_."email" as email1_0_, fk_person0_."personid" as personid2_1_0_ from adr."email" fk_person0_ where fk_person0_."personid"=?
Hibernate: select fk_person0_."personid" as personid2___, fk_person0_."email" as email1___, fk_person0_."email" as email1_0_, fk_person0_."personid" as personid2_1_0_ from adr."email" fk_person0_ where fk_person0_."personid"=?
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
25188 [AWT-EventQueue-0] DEBUG org.hibernate.type.IntegerType - binding '7' to parameter: 1
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - result set contains (possibly empty) collection: [db.Person.Fk_person#component[Pid]{Pid=7}]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.engine.CollectionLoadContext - uninitialized collection: initializing
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - processing result set
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - done processing result set (0 rows)
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
25188 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - total objects hydrated: 0
25188 [AWT-EventQueue-0] DEBUG org.hibernate.engine.CollectionLoadContext - 1 collections were found in result set
25188 [AWT-EventQueue-0] DEBUG org.hibernate.engine.CollectionLoadContext - collection fully initialized: [db.Person.Fk_person#component[Pid]{Pid=7}]
25188 [AWT-EventQueue-0] DEBUG org.hibernate.engine.CollectionLoadContext - 1 collections initialized
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - done loading collection
25188 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.DefaultInitializeCollectionEventListener - collection initialized
25188 [AWT-EventQueue-0] DEBUG org.hibernate.loader.Loader - done entity load
abcd
25188 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - flushing session
25188 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
25188 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
25188 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
25188 [AWT-EventQueue-0] DEBUG org.hibernate.persister.entity.BasicEntityPersister - db.Person.Adresse is dirty
25188 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.DefaultFlushEntityEventListener - Updating entity: [db.Person#7]
25203 [AWT-EventQueue-0] DEBUG org.hibernate.engine.Collections - Collection found: [db.Person.Fk_person#component[Pid]{Pid=7}], was: [db.Person.Fk_person#component[Pid]{Pid=7}] (initialized)
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections
25203 [AWT-EventQueue-0] DEBUG org.hibernate.pretty.Printer - listing entities:
25203 [AWT-EventQueue-0] DEBUG org.hibernate.pretty.Printer - db.Person{Adresse=abcd, Pid=7, propfk_person=component[Pid]{Pid=7}, Fk_person=[], Name=Sven}
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush
25203 [AWT-EventQueue-0] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Updating entity: [db.Person#7]
25203 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
25203 [AWT-EventQueue-0] DEBUG org.hibernate.SQL - update adr."person" set "name"=?, "adresse"=? where "pid"=?
Hibernate: update adr."person" set "name"=?, "adresse"=? where "pid"=?
25203 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
25203 [AWT-EventQueue-0] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Dehydrating entity: [db.Person#7]
25203 [AWT-EventQueue-0] DEBUG org.hibernate.type.StringType - binding 'Sven' to parameter: 1
25203 [AWT-EventQueue-0] DEBUG org.hibernate.type.StringType - binding 'abcd' to parameter: 2
25203 [AWT-EventQueue-0] DEBUG org.hibernate.type.IntegerType - binding '7' to parameter: 3
25203 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - Adding to batch
25203 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1
25203 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
25203 [AWT-EventQueue-0] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - post flush
25203 [AWT-EventQueue-0] DEBUG org.hibernate.transaction.JDBCTransaction - commit
25203 [AWT-EventQueue-0] DEBUG org.hibernate.impl.SessionImpl - automatically flushing session
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - flushing session
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
25203 [AWT-EventQueue-0] DEBUG org.hibernate.engine.Collections - Collection found: [db.Person.Fk_person#<null>], was: [db.Person.Fk_person#component[Pid]{Pid=7}] (initialized)
25203 [AWT-EventQueue-0] DEBUG org.hibernate.engine.Collections - Forcing collection initialization
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 (re)creations, 0 updates, 1 removals to 1 collections
25203 [AWT-EventQueue-0] DEBUG org.hibernate.pretty.Printer - listing entities:
25203 [AWT-EventQueue-0] DEBUG org.hibernate.pretty.Printer - db.Person{Adresse=abcd, Pid=7, propfk_person=component[Pid]{Pid=7}, Fk_person=[], Name=Sven}
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush
25203 [AWT-EventQueue-0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - post flush
I retrieve these exceptions on the tx.commit() line.
I localized the error in
Code:
AbstractFlushingEventListener
Method
Code:
postFlush(...)
in statement
Code:
persistenceContext.getCollectionsByKey().put(
new CollectionKey( ce.getCurrentPersister(), ce.getCurrentKey(), session.getEntityMode() ),pc);
The call to ce.getCurrentKey() results to null. That causes the NPE on calling 'invoke' on the property-getter, because the object is null.
Can anyone help me?