From: <one...@us...> - 2003-03-13 03:16:22
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv27048/sf/hibernate/impl Modified Files: QueryImpl.java SessionImpl.java Log Message: improved handing of proxies in QueryImpl don't initialize proxies in update() or saveOrUpdate() added Session.refresh(Object, LockMode) Index: QueryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/QueryImpl.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** QueryImpl.java 12 Mar 2003 12:28:58 -0000 1.11 --- QueryImpl.java 13 Mar 2003 03:16:00 -0000 1.12 *************** *** 174,180 **** } ! public Query setEntity(int position, Object val) throws HibernateException { ! val = HibernateProxyHelper.unproxy(val, session); ! setParameter( position, val, Hibernate.association( val.getClass() ) ); return this; } --- 174,179 ---- } ! public Query setEntity(int position, Object val) { ! setParameter( position, val, Hibernate.association( HibernateProxyHelper.getClass(val) ) ); return this; } *************** *** 230,236 **** } ! public Query setEntity(String name, Object val) throws HibernateException { ! val = HibernateProxyHelper.unproxy(val, session); ! setParameter( name, val, Hibernate.association( val.getClass() ) ); return this; } --- 229,234 ---- } ! public Query setEntity(String name, Object val) { ! setParameter( name, val, Hibernate.association( HibernateProxyHelper.getClass(val) ) ); return this; } *************** *** 322,327 **** private Type guessType(Object param) throws HibernateException { ! param = HibernateProxyHelper.unproxy(param, session); ! Class clazz = param.getClass(); return guessType(clazz); } --- 320,324 ---- private Type guessType(Object param) throws HibernateException { ! Class clazz = HibernateProxyHelper.getClass(param); return guessType(clazz); } *************** *** 397,401 **** public Query setProperties(Object bean) throws HibernateException { - bean = HibernateProxyHelper.unproxy(bean, session); Class clazz = bean.getClass(); Iterator iter = session.getFactory().getNamedParameters(queryString).iterator(); --- 394,397 ---- Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** SessionImpl.java 8 Mar 2003 06:31:22 -0000 1.25 --- SessionImpl.java 13 Mar 2003 03:16:01 -0000 1.26 *************** *** 27,30 **** --- 27,31 ---- import net.sf.hibernate.Criteria; import net.sf.hibernate.FlushMode; + import net.sf.hibernate.Hibernate; import net.sf.hibernate.HibernateException; import net.sf.hibernate.Interceptor; *************** *** 1027,1030 **** --- 1028,1032 ---- if (obj==null) throw new NullPointerException("attempted to update null"); + if ( !Hibernate.isInitialized(obj) ) return; Object object = HibernateProxyHelper.unproxy(obj, this); *************** *** 1062,1065 **** --- 1064,1068 ---- public void saveOrUpdate(Object obj) throws HibernateException { if (obj==null) throw new NullPointerException("attempted to update null"); + if ( !Hibernate.isInitialized(obj) ) return; Object object = HibernateProxyHelper.unproxy(obj, this); *************** *** 1119,1122 **** --- 1122,1126 ---- if (id==null) throw new NullPointerException("null is not a valid identifier"); if (obj==null) throw new NullPointerException("attempted to update null"); + if ( !Hibernate.isInitialized(obj) ) return; Object object = HibernateProxyHelper.unproxy(obj, this); *************** *** 1754,1757 **** --- 1758,1765 ---- public void refresh(Object object) throws HibernateException { + refresh(object, LockMode.READ); + } + + public void refresh(Object object, LockMode lockMode) throws HibernateException { if (object==null) throw new NullPointerException("attempted to refresh null"); *************** *** 1764,1768 **** removeEntity( new Key(e.id, e.persister) ); try { ! e.persister.load( e.id, object, LockMode.READ, this); } catch (SQLException sqle) { --- 1772,1776 ---- removeEntity( new Key(e.id, e.persister) ); try { ! e.persister.load( e.id, object, lockMode, this); } catch (SQLException sqle) { |