@Override public void reassociateProxy(Object value, Serializable id) throws MappingException { if ( value instanceof HibernateProxy ) { LOG.debugf( "Setting proxy identifier: %s", id ); final HibernateProxy proxy = (HibernateProxy) value; final LazyInitializer li = proxy.getHibernateLazyInitializer(); li.setIdentifier( id ); reassociateProxy( li, proxy ); } }
/** * Handle the given update event. * * @param event The update event to be handled. */ public void onSaveOrUpdate(SaveOrUpdateEvent event) { final SessionImplementor source = event.getSession(); final Object object = event.getObject(); final Serializable requestedId = event.getRequestedId(); if ( requestedId != null ) { //assign the requested id to the proxy, *before* //reassociating the proxy if ( object instanceof HibernateProxy ) { ( (HibernateProxy) object ).getHibernateLazyInitializer().setIdentifier( requestedId ); } } // For an uninitialized proxy, noop, don't even need to return an id, since it is never a save() if ( reassociateIfUninitializedProxy( object, source ) ) { LOG.trace( "Reassociated uninitialized proxy" ); } else { //initialize properties of the event: final Object entity = source.getPersistenceContext().unproxyAndReassociate( object ); event.setEntity( entity ); event.setEntry( source.getPersistenceContext().getEntry( entity ) ); //return the id in the event object event.setResultId( performSaveOrUpdate( event ) ); } }
/** * If a deleted entity instance is re-saved, and it has a proxy, we need to * reset the identifier of the proxy */ public void reassociateProxy(Object value, Serializable id) throws MappingException { if ( value instanceof ElementWrapper ) { value = ( (ElementWrapper) value ).getElement(); } if ( value instanceof HibernateProxy ) { if ( log.isDebugEnabled() ) log.debug("setting proxy identifier: " + id); HibernateProxy proxy = (HibernateProxy) value; LazyInitializer li = proxy.getHibernateLazyInitializer(); li.setIdentifier(id); reassociateProxy(li, proxy); } }
private void setRawIdentifier(Serializable id) { this.lazyInitializer.setIdentifier(id); if (!this.isUninitialized() && !this.disableSetTargetIdentifier) { try { Method setIdentifierMethod = this.setIdentifierMethod; if (!setIdentifierMethod.isAccessible()) { setIdentifierMethod.setAccessible(true); } this.disableTargetListener = true; try { setIdentifierMethod.invoke(this.getImplementation(), new Object[] { id }); } finally { this.disableTargetListener = false; } } catch (IllegalAccessException | IllegalArgumentException ex) { throw new AssertionError("Internal bug", ex); } catch (InvocationTargetException ex) { UncheckedException.rethrow(ex.getTargetException()); } } }
/** * If a deleted entity instance is re-saved, and it has a proxy, we need to * reset the identifier of the proxy */ public void reassociateProxy(Object value, Serializable id) throws MappingException { if ( value instanceof ElementWrapper ) { value = ( (ElementWrapper) value ).getElement(); } if ( value instanceof HibernateProxy ) { if ( log.isDebugEnabled() ) log.debug("setting proxy identifier: " + id); HibernateProxy proxy = (HibernateProxy) value; LazyInitializer li = proxy.getHibernateLazyInitializer(); li.setIdentifier(id); reassociateProxy(li, proxy); } }
@Override public void reassociateProxy(Object value, Object id) throws MappingException { if ( value instanceof HibernateProxy ) { LOG.debugf( "Setting proxy identifier: %s", id ); final HibernateProxy proxy = (HibernateProxy) value; final LazyInitializer li = proxy.getHibernateLazyInitializer(); li.setIdentifier( id ); reassociateProxy( li, proxy ); } }
/** * If a deleted entity instance is re-saved, and it has a proxy, we need to * reset the identifier of the proxy */ @Override public void reassociateProxy(Object value, Serializable id) throws MappingException { if ( value instanceof ElementWrapper ) { value = ( (ElementWrapper) value ).getElement(); } if ( value instanceof HibernateProxy ) { LOG.debugf( "Setting proxy identifier: %s", id ); HibernateProxy proxy = (HibernateProxy) value; LazyInitializer li = proxy.getHibernateLazyInitializer(); li.setIdentifier(id); reassociateProxy(li, proxy); } }
/** * If a deleted entity instance is re-saved, and it has a proxy, we need to * reset the identifier of the proxy */ @Override public void reassociateProxy(Object value, Serializable id) throws MappingException { if ( value instanceof ElementWrapper ) { value = ( (ElementWrapper) value ).getElement(); } if ( value instanceof HibernateProxy ) { LOG.debugf( "Setting proxy identifier: %s", id ); HibernateProxy proxy = (HibernateProxy) value; LazyInitializer li = proxy.getHibernateLazyInitializer(); li.setIdentifier(id); reassociateProxy(li, proxy); } }
( (HibernateProxy) object ).getHibernateLazyInitializer().setIdentifier(requestedId);
( (HibernateProxy) object ).getHibernateLazyInitializer().setIdentifier(requestedId);
/** * Handle the given update event. * * @param event The update event to be handled. */ public void onSaveOrUpdate(SaveOrUpdateEvent event) { final SessionImplementor source = event.getSession(); final Object object = event.getObject(); final Serializable requestedId = event.getRequestedId(); if ( requestedId != null ) { //assign the requested id to the proxy, *before* //reassociating the proxy if ( object instanceof HibernateProxy ) { ( ( HibernateProxy ) object ).getHibernateLazyInitializer().setIdentifier( requestedId ); } } // For an uninitialized proxy, noop, don't even need to return an id, since it is never a save() if ( reassociateIfUninitializedProxy( object, source ) ) { LOG.trace( "Reassociated uninitialized proxy" ); } else { //initialize properties of the event: final Object entity = source.getPersistenceContext().unproxyAndReassociate( object ); event.setEntity( entity ); event.setEntry( source.getPersistenceContext().getEntry( entity ) ); //return the id in the event object event.setResultId( performSaveOrUpdate( event ) ); } }
/** * Handle the given update event. * * @param event The update event to be handled. */ public void onSaveOrUpdate(SaveOrUpdateEvent event) { final SessionImplementor source = event.getSession(); final Object object = event.getObject(); final Serializable requestedId = event.getRequestedId(); if ( requestedId != null ) { //assign the requested id to the proxy, *before* //reassociating the proxy if ( object instanceof HibernateProxy ) { ( ( HibernateProxy ) object ).getHibernateLazyInitializer().setIdentifier( requestedId ); } } // For an uninitialized proxy, noop, don't even need to return an id, since it is never a save() if ( reassociateIfUninitializedProxy( object, source ) ) { LOG.trace( "Reassociated uninitialized proxy" ); } else { //initialize properties of the event: final Object entity = source.getPersistenceContext().unproxyAndReassociate( object ); event.setEntity( entity ); event.setEntry( source.getPersistenceContext().getEntry( entity ) ); //return the id in the event object event.setResultId( performSaveOrUpdate( event ) ); } }
/** * Handle the given update event. * * @param event The update event to be handled. */ public void onSaveOrUpdate(SaveOrUpdateEvent event) { final SessionImplementor source = event.getSession(); final Object object = event.getObject(); final Object requestedId = event.getRequestedId(); if ( requestedId != null ) { //assign the requested id to the proxy, *before* //reassociating the proxy if ( object instanceof HibernateProxy ) { ( (HibernateProxy) object ).getHibernateLazyInitializer().setIdentifier( requestedId ); } } // For an uninitialized proxy, noop, don't even need to return an id, since it is never a save() if ( reassociateIfUninitializedProxy( object, source ) ) { LOG.trace( "Reassociated uninitialized proxy" ); } else { //initialize properties of the event: final Object entity = source.getPersistenceContext().unproxyAndReassociate( object ); event.setEntity( entity ); event.setEntry( source.getPersistenceContext().getEntry( entity ) ); //return the id in the event object event.setResultId( performSaveOrUpdate( event ) ); } }