From: <one...@us...> - 2002-11-05 11:48:12
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl In directory usw-pr-cvs1:/tmp/cvs-serv20016/hibernate/impl Modified Files: ScheduledUpdate.java SessionImpl.java Log Message: for normalized table mappings, only update the tables that have dirty properties Index: ScheduledUpdate.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/ScheduledUpdate.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ScheduledUpdate.java 1 Oct 2002 01:25:30 -0000 1.18 --- ScheduledUpdate.java 5 Nov 2002 11:48:07 -0000 1.19 *************** *** 14,27 **** private final Object[] fields; private final Object lastVersion; ! public ScheduledUpdate(Serializable id, Object[] fields, Object lastVersion, Object instance, ClassPersister persister, SessionImplementor session) { super(session, id, instance, persister); this.fields = fields; this.lastVersion = lastVersion; } public void execute() throws SQLException, HibernateException { if ( persister.hasCache() ) persister.getCache().lock(id); ! persister.update(id, fields, lastVersion, instance, session); } --- 14,29 ---- private final Object[] fields; private final Object lastVersion; + private final int[] dirtyFields; ! public ScheduledUpdate(Serializable id, Object[] fields, int[] dirtyProperties, Object lastVersion, Object instance, ClassPersister persister, SessionImplementor session) { super(session, id, instance, persister); this.fields = fields; this.lastVersion = lastVersion; + this.dirtyFields = dirtyProperties; } public void execute() throws SQLException, HibernateException { if ( persister.hasCache() ) persister.getCache().lock(id); ! persister.update(id, fields, dirtyFields, lastVersion, instance, session); } Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/SessionImpl.java,v retrieving revision 1.146 retrieving revision 1.147 diff -C2 -d -r1.146 -r1.147 *** SessionImpl.java 2 Nov 2002 14:32:12 -0000 1.146 --- SessionImpl.java 5 Nov 2002 11:48:07 -0000 1.147 *************** *** 1770,1779 **** boolean substitute = wrap(values, types); // substitutes into values by side-effect ! // compare to cached state (ignoring nested collections) if ( ! /*( status==LOADED &&*/ entry.loadedState==null || // object loaded by update() ! persister.isDirty(values, entry.loadedState, object, this) || ! ( status==LOADED && persister.isVersioned() && persister.hasCollections() && searchForDirtyCollections(values, types) ) ) { // its dirty! --- 1770,1792 ---- boolean substitute = wrap(values, types); // substitutes into values by side-effect ! ! boolean noCleanState = entry.loadedState==null; // object loaded by update() ! final int[] dirtyProperties; ! if (!noCleanState) { ! dirtyProperties = persister.findDirty(values, entry.loadedState, object, this); ! } ! else { ! dirtyProperties = null; ! } ! // compare to cached state (ignoring nested collections) if ( ! noCleanState || ! (dirtyProperties!=null) || ( ! status==LOADED && ! persister.isVersioned() && ! persister.hasCollections() && ! searchForDirtyCollections(values, types) ! ) ) { // its dirty! *************** *** 1790,1799 **** Object[] copiedValues = new Object[values.length]; TypeFactory.deepCopy(values, types, copiedValues); ! entry.loadedState = copiedValues; //for next time ! //entry.wasCached = false; ! entry.nextLockMode = LockMode.WRITE; //if this flush completes successfully, we will have an exclusive lock } ! //increment the version number (if necessary) if ( persister.isVersioned() ) { if (status!=DELETED) entry.nextVersion = Versioning.increment( entry.lastVersion, persister.getVersionType() ); --- 1803,1811 ---- Object[] copiedValues = new Object[values.length]; TypeFactory.deepCopy(values, types, copiedValues); ! entry.loadedState = copiedValues; // for next time ! entry.nextLockMode = LockMode.WRITE; // if this flush goes ahead, we will have a write lock } ! // increment the version number (if necessary) if ( persister.isVersioned() ) { if (status!=DELETED) entry.nextVersion = Versioning.increment( entry.lastVersion, persister.getVersionType() ); *************** *** 1804,1808 **** updates.put( new Key(entry.id, persister), ! new ScheduledUpdate( entry.id, values, entry.lastVersion, object, persister, this ) ); --- 1816,1820 ---- updates.put( new Key(entry.id, persister), ! new ScheduledUpdate( entry.id, values, dirtyProperties, entry.lastVersion, object, persister, this ) ); *************** *** 1810,1814 **** if (status==DELETED) { ! entry.status = GONE; //for next time } else { --- 1822,1826 ---- if (status==DELETED) { ! entry.status = GONE; //for next time } else { *************** *** 1820,1824 **** // Search for collections by reachability, updating their role. // We don't want to touch collections reachable from a deleted object - updateReachables(values, types, object); } --- 1832,1835 ---- |