[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-1266) StatelessSession can implement refresh
Steve Ebersole (JIRA)
noreply at atlassian.com
Mon Mar 21 13:00:47 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Steve Ebersole closed HHH-1266.
-------------------------------
Closing stale resolved issues
> StatelessSession can implement refresh
> --------------------------------------
>
> Key: HHH-1266
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1266
> Project: Hibernate Core
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.1
> Reporter: Barthel Steckemetz
> Assignee: Steve Ebersole
> Priority: Minor
> Fix For: 3.2.0.cr2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The refresh method in StatelessSession is missing.
> I took the following implementation from DefaultRefreshEventListener onRefresh
> and modified it. As the stateless Session does not support collection loading,
> proxies and eviction the relevant lines are commented.
> StatelessSessionImpl:
> public void refresh(Object object) throws HibernateException {
> refresh(object, LockMode.READ);
> }
>
> // code taken from DefaultRefreshEventListener onRefresh
> public void refresh( Object obj, LockMode lockMode ) throws HibernateException {
> final AbstractSessionImpl source = this;
>
> // not applicable in stateless session: if ( source.getPersistenceContext().reassociateIfUninitializedProxy( obj ) ) return;
> final Object object = obj; // BST source.getPersistenceContext().unproxyAndReassociate( obj );
> // not applicable in stateless session:
> // if ( refreshedAlready.containsKey(object) ) {
> // log.trace("already refreshed");
> // return;
> // }
> final EntityEntry e = source.getPersistenceContext().getEntry( object );
> final EntityPersister persister;
> final Serializable id;
> Log log = LogFactory.getLog(this.getClass());
>
> if ( e == null ) {
> persister = source.getEntityPersister(null, object); //refresh() does not pass an entityName
> id = persister.getIdentifier( object, getEntityMode() );
> if ( log.isTraceEnabled() ) {
> log.trace(
> "refreshing transient " +
> MessageHelper.infoString( persister, id, source.getFactory() )
> );
> }
> EntityKey key = new EntityKey( id, persister, source.getEntityMode() );
> if ( source.getPersistenceContext().getEntry(key) != null ) {
> throw new PersistentObjectException(
> "attempted to refresh transient instance when persistent instance was already associated with the Session: " +
> MessageHelper.infoString(persister, id, source.getFactory() )
> );
> }
> }
> else {
> if ( log.isTraceEnabled() ) {
> log.trace(
> "refreshing " +
> MessageHelper.infoString( e.getPersister(), e.getId(), source.getFactory() )
> );
> }
> if ( !e.isExistsInDatabase() ) {
> throw new HibernateException( "this instance does not yet exist as a row in the database" );
> }
> persister = e.getPersister();
> id = e.getId();
> }
> // cascade the refresh prior to refreshing this entity
> // not applicable in stateless session: refreshedAlready.put(object, object);
> // new Cascade(CascadingAction.REFRESH, Cascade.BEFORE_REFRESH, source)
> // .cascade( persister, object, refreshedAlready );
> if ( e != null ) {
> EntityKey key = new EntityKey( id, persister, source.getEntityMode() );
> source.getPersistenceContext().removeEntity(key);
> // not applicable in stateless session: if ( persister.hasCollections() ) new EvictVisitor( source ).process(object, persister);
> }
> if ( persister.hasCache() ) {
> final CacheKey ck = new CacheKey(
> id,
> persister.getIdentifierType(),
> persister.getRootEntityName(),
> source.getEntityMode(),
> source.getFactory()
> );
> persister.getCache().remove(ck);
> }
>
> // not applicable in stateless session: evictCachedCollections( persister, id, source.getFactory() );
>
> String previousFetchProfile = source.getFetchProfile();
> source.setFetchProfile("refresh");
> Object result = persister.load( id, object, lockMode, source );
> source.setFetchProfile(previousFetchProfile);
>
> UnresolvableObjectException.throwIfNull( result, id, persister.getEntityName() );
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list