From: <one...@us...> - 2003-01-02 11:01:53
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv30125/src/net/sf/hibernate/impl Modified Files: SessionImpl.java Log Message: changed default unsaved-value changed 'role' attribute to 'name' added a new check/exception in delete() Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SessionImpl.java 1 Jan 2003 15:12:52 -0000 1.2 --- SessionImpl.java 2 Jan 2003 11:01:49 -0000 1.3 *************** *** 502,508 **** if ( isEntryFor(object) ) throw new PersistentObjectException( ! "attempted to save an instance of " + ! persister.getClassName() + ! " that was already associated with the Session" ); --- 502,506 ---- if ( isEntryFor(object) ) throw new PersistentObjectException( ! "attempted to save an instance of that was already associated with the Session: " + infoString(persister, id) ); *************** *** 526,530 **** key = new Key(id, persister); ! if ( getEntity(key) != null ) throw new HibernateException("The generated ID is already in use" + infoString(persister, id)); persister.setIdentifier(object, id); --- 524,528 ---- key = new Key(id, persister); ! if ( getEntity(key) != null ) throw new HibernateException("The generated ID is already in use: " + infoString(persister, id)); persister.setIdentifier(object, id); *************** *** 701,704 **** --- 699,708 ---- persister = getPersister(object); Serializable id = persister.getIdentifier(object); + + Object old = getEntity( new Key(id, persister) ); + + if (old!=null) { + throw new HibernateException( "Another object with the same id was already associated with the session: " + infoString(persister, id) ); + } removeCollectionsFor(persister, id, object); *************** *** 719,723 **** persister = entry.persister; } ! if ( !persister.isMutable() ) throw new HibernateException( "attempted to delete an object of immutable class: " + infoString(persister)); --- 723,727 ---- persister = entry.persister; } ! if ( !persister.isMutable() ) throw new HibernateException( "attempted to delete an object of immutable class: " + infoString(persister) ); *************** *** 964,968 **** else if ( old!=null ) { throw new HibernateException( ! "Another object was associated with this id (the object with the given id was already loaded) " + infoString(persister, id) ); --- 968,972 ---- else if ( old!=null ) { throw new HibernateException( ! "Another object was associated with this id (the object with the given id was already loaded): " + infoString(persister, id) ); *************** *** 1351,1359 **** private void doLoadByObject(Object object, Serializable id, boolean checkDeleted) throws SQLException, HibernateException { - if ( getEntry(object)!=null ) throw new PersistentObjectException("attempted to load into an instance that was already associated with the Session"); Class clazz = object.getClass(); Object result = doLoad(clazz, id, object, LockMode.NONE, checkDeleted); throwObjectNotFound(result, id, clazz); ! if (result!=object) throw new HibernateException("The object with that id was already loaded by the Session: " + id); } --- 1355,1369 ---- private void doLoadByObject(Object object, Serializable id, boolean checkDeleted) throws SQLException, HibernateException { Class clazz = object.getClass(); + if ( getEntry(object)!=null ) throw new PersistentObjectException( + "attempted to load into an instance that was already associated with the Session: " + + infoString(clazz, id) + ); Object result = doLoad(clazz, id, object, LockMode.NONE, checkDeleted); throwObjectNotFound(result, id, clazz); ! if (result!=object) throw new HibernateException( ! "The object with that id was already loaded by the Session: " + ! infoString(clazz, id) ! ); } |