From: Max R. A. <max...@jb...> - 2006-07-21 14:43:01
|
submit a patch in jira that sends it to log.trace (in less than 4 = individual lines ;) and we will consider it. /max > Hi, > > I'm trying to debug/fix Hibernate messages like = > "org.hibernate.NonUniqueObjectException: a different object with the = > same identifier value was already associated with the session: "... an= d = > I find the default exception logging in = > AbstractSaveEventListener#performSave not sufficient. I've added some = = > System.err.printlns() with the information I typically need. It would = be = > great if this debug info would make it somehow into the latest SVN. > > Rgds > Holger > > /** > * Ppepares the save call by checking the session caches for a = > pre-existing > * entity and performing any lifecycle callbacks. > * @param entity The entity to be saved. > * @param id The id by which to save the entity. > * @param persister The entity's persister instance. > * @param useIdentityColumn Is an identity column in use? > * @param source The session from which the event originated. > * @param requiresImmediateIdAccess does the event context require > * access to the identifier immediately after execution of this metho= d = > (if > * not, post-insert style id generators may be postponed if we are = > outside > * a transaction). > * @return The id used to save the entity; may be null depending on t= he > * type of id generator used and the requiresImmediateIdAccess value > * @throws HibernateException > */ > protected Serializable performSave( > Object entity, > Serializable id, > EntityPersister persister, > boolean useIdentityColumn, > Object anything, > EventSource source, > boolean requiresImmediateIdAccess) > throws HibernateException { > > if ( log.isTraceEnabled() ) { > log.trace( > "saving " + > MessageHelper.infoString( persister, id, source.getFactory() ) > ); > } > = > EntityKey key; > if ( !useIdentityColumn ) { > key =3D new EntityKey( id, persister, source.getEntityMode() ); > Object old =3D source.getPersistenceContext().getEntity(key); > if (old !=3D null) { > if ( source.getPersistenceContext().getEntry(old).getStatus() =3D=3D= = > Status.DELETED ) { > source.forceFlush( source.getPersistenceContext().getEntry(old) )= ; > } > else { > System.err.println("old: " + old); > System.err.println("old.class: " + old.getClass()); > System.err.println("entity: " + entity); > System.err.println("entity.class: " + entity.getClass()); > System.err.println("id: " + id); > throw new NonUniqueObjectException( id, persister.getEntityName()= ); > } > } > persister.setIdentifier(entity, id, source.getEntityMode()); > } > else { > key =3D null; > } > = > if ( invokeSaveLifecycle(entity, persister, source) ) { > return id; //EARLY EXIT > } > > return performSaveOrReplicate( > entity, > key, > persister, > useIdentityColumn, > anything, > source, > requiresImmediateIdAccess > ); > } > -- = -- Max Rydahl Andersen callto://max.rydahl.andersen Hibernate ma...@hi... http://hibernate.org JBoss Inc max...@jb... |