-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Exception on commit
PostPosted: Sun Nov 20, 2005 4:42 pm 
Newbie

Joined: Sun Nov 20, 2005 4:05 pm
Posts: 2
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=false

Code:
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?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 3:36 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Not sure if this solves your problem, but you don't need Session.flush - Transaction.commit() indirectly call Session.flush(). What happens when commenting out either of these lines?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 4:26 am 
Newbie

Joined: Sun Nov 20, 2005 4:05 pm
Posts: 2
Thanks very much, Dennis!

Commenting out 'session.flush();' helped!

I think I haven't fully understood the update-concept.
Can you tell me, when session.flush has to be used?

Thanks,
Chris


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 10:06 am 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
As far as I know it just sincronyzes the states of objects with the table states, WITHOUT commiting.
If you use ids generated, for instance, flush() might help you not to get pk violations... because when you call it, it will "update" the object and if there's an other with the same id, it will change it.

Hibernate will flush automatically periodically, but sometimes you must do it manually to guarantee.

In your case, well, I don't really know why the problem happened.

_________________
Don't forget to rate if the post helped!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 11:29 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
There's an interesting discussion on the dev mailling list about flush right now ... http://sourceforge.net/mailarchive/foru ... um_id=7517


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 22, 2005 6:46 am 
Beginner
Beginner

Joined: Wed Oct 05, 2005 12:29 pm
Posts: 22
I have a different observation. I actually find that commit() does not seems to do a flush automatically.

My scenario is very typical. I have a listing.jsf page which contains a list of records, one column is a delete button for deleting a particular record. I have a HibernateLongFilter for saving the session in httpsession and reattaching it on the next request.

When the delete button is pressed the page does a submit, activates a method to do the deletion, then forward to listing.jsf again which retrieves the updated for display.

I tried various combinations and found some very puzzling result.

(1) Doesn't work
Begin transaction
Delete record
Retrieve Listing
Commit

(2) Works OK apparently
begin transaction
delete record
flush
retrieve listing
commit

(3) Doesn't work
begin transaction
delete record
commit
retrieve listing

(4) Works OK
begin transaction
delete record
commit
flush
retrieve listing

Doesn't work means the record is not deleted. I am using (4) as it is the safest. But I am buffled why (2) doesn't work while (3) works.

Can someone explain?

Thanks
Yee


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 22, 2005 6:50 am 
Beginner
Beginner

Joined: Wed Oct 05, 2005 12:29 pm
Posts: 22
I forgot to mention that works OK also include the listing contains the updated result. So (2) will show the listing without the deleted record.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.