org.hibernate.UnresolvableObjectException Java Examples

The following examples show how to use org.hibernate.UnresolvableObjectException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable)
		throws HibernateException {
	// todo : remove
	LoadEventListener.LoadType type = nullable
			? LoadEventListener.INTERNAL_LOAD_NULLABLE
			: eager
			? LoadEventListener.INTERNAL_LOAD_EAGER
			: LoadEventListener.INTERNAL_LOAD_LAZY;

	LoadEvent event = loadEvent;
	loadEvent = null;
	event = recycleEventInstance( event, id, entityName );
	fireLoad( event, type );
	Object result = event.getResult();
	if ( !nullable ) {
		UnresolvableObjectException.throwIfNull( result, id, entityName );
	}
	if ( loadEvent == null ) {
		event.setEntityClassName( null );
		event.setEntityId( null );
		event.setInstanceToLoad( null );
		event.setResult( null );
		loadEvent = event;
	}
	return result;
}
 
Example #2
Source File: SessionImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException {
	// todo : remove
	LoadEventListener.LoadType type = nullable ? 
			LoadEventListener.INTERNAL_LOAD_NULLABLE : 
			eager ? LoadEventListener.INTERNAL_LOAD_EAGER : LoadEventListener.INTERNAL_LOAD_LAZY;
	LoadEvent event = new LoadEvent(id, entityName, true, this);
	fireLoad(event, type);
	if ( !nullable ) {
		UnresolvableObjectException.throwIfNull( event.getResult(), id, entityName );
	}
	return event.getResult();
}
 
Example #3
Source File: HibernateObjectRetrievalFailureException.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public HibernateObjectRetrievalFailureException(UnresolvableObjectException ex) {
	super(ex.getEntityName(), ex.getIdentifier(), ex.getMessage(), ex);
}
 
Example #4
Source File: HibernateObjectRetrievalFailureException.java    From java-technology-stack with MIT License 4 votes vote down vote up
public HibernateObjectRetrievalFailureException(UnresolvableObjectException ex) {
	super(ex.getEntityName(), ex.getIdentifier(), ex.getMessage(), ex);
}
 
Example #5
Source File: HibernateObjectRetrievalFailureException.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public HibernateObjectRetrievalFailureException(UnresolvableObjectException ex) {
	super(ex.getEntityName(), ex.getIdentifier(), ex.getMessage(), ex);
}
 
Example #6
Source File: HibernateObjectRetrievalFailureException.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public HibernateObjectRetrievalFailureException(UnresolvableObjectException ex) {
	super(ex.getEntityName(), ex.getIdentifier(), ex.getMessage(), ex);
}
 
Example #7
Source File: HibernateObjectRetrievalFailureException.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public HibernateObjectRetrievalFailureException(UnresolvableObjectException ex) {
	super(ex.getEntityName(), ex.getIdentifier(), ex.getMessage(), ex);
}
 
Example #8
Source File: StatelessSessionImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
	public void refresh(String entityName, Object entity, LockMode lockMode) {
		final EntityPersister persister = this.getEntityPersister( entityName, entity );
		final Serializable id = persister.getIdentifier( entity, this );
		if ( LOG.isTraceEnabled() ) {
			LOG.tracev( "Refreshing transient {0}", MessageHelper.infoString( persister, id, this.getFactory() ) );
		}
		// TODO : can this ever happen???
//		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() )
//			);
//		}

		if ( persister.canWriteToCache() ) {
			final EntityDataAccess cacheAccess = persister.getCacheAccessStrategy();
			if ( cacheAccess != null ) {
				final Object ck = cacheAccess.generateCacheKey(
						id,
						persister,
						getFactory(),
						getTenantIdentifier()
				);
				cacheAccess.evict( ck );
			}
		}

		String previousFetchProfile = this.getLoadQueryInfluencers().getInternalFetchProfile();
		Object result = null;
		try {
			this.getLoadQueryInfluencers().setInternalFetchProfile( "refresh" );
			result = persister.load( id, entity, getNullSafeLockMode( lockMode ), this );
		}
		finally {
			this.getLoadQueryInfluencers().setInternalFetchProfile( previousFetchProfile );
		}
		UnresolvableObjectException.throwIfNull( result, id, persister.getEntityName() );
	}
 
Example #9
Source File: HibernateObjectRetrievalFailureException.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public HibernateObjectRetrievalFailureException(UnresolvableObjectException ex) {
	super(ex.getEntityName(), ex.getIdentifier(), ex.getMessage(), ex);
}
 
Example #10
Source File: HibernateObjectRetrievalFailureException.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public HibernateObjectRetrievalFailureException(UnresolvableObjectException ex) {
	super(ex.getEntityName(), ex.getIdentifier(), ex.getMessage(), ex);
}
 
Example #11
Source File: HibernateObjectRetrievalFailureException.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public HibernateObjectRetrievalFailureException(UnresolvableObjectException ex) {
	super(ex.getEntityName(), ex.getIdentifier(), ex.getMessage(), ex);
}
 
Example #12
Source File: StandardQueryCache.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public List get(
		QueryKey key,
		Type[] returnTypes,
		boolean isNaturalKeyLookup,
		Set spaces,
		SessionImplementor session) throws HibernateException {
	if ( log.isDebugEnabled() ) {
		log.debug("checking cached query results in region: " + regionName);
	}

	List cacheable = (List) queryCache.get(key);
	if (cacheable==null) {
		log.debug("query results were not found in cache");
		return null;
	}

	Long timestamp = (Long) cacheable.get(0);
	if ( !isNaturalKeyLookup && !isUpToDate(spaces, timestamp) ) {
		log.debug("cached query results were not up to date");
		return null;
	}

	log.debug("returning cached query results");
	for ( int i=1; i<cacheable.size(); i++ ) {
		if ( returnTypes.length==1 ) {
			returnTypes[0].beforeAssemble( (Serializable) cacheable.get(i), session );
		}
		else {
			TypeFactory.beforeAssemble( (Serializable[]) cacheable.get(i), returnTypes, session );
		}
	}
	List result = new ArrayList( cacheable.size()-1 );
	for ( int i=1; i<cacheable.size(); i++ ) {
		try {
			if ( returnTypes.length==1 ) {
				result.add( returnTypes[0].assemble( (Serializable) cacheable.get(i), session, null ) );
			}
			else {
				result.add( TypeFactory.assemble( (Serializable[]) cacheable.get(i), returnTypes, session, null ) );
			}
		}
		catch (UnresolvableObjectException uoe) {
			if (isNaturalKeyLookup) {
				//TODO: not really completely correct, since
				//      the uoe could occur while resolving
				//      associations, leaving the PC in an
				//      inconsistent state
				log.debug("could not reassemble cached result set");
				queryCache.remove(key);
				return null;
			}
			else {
				throw uoe;
			}
		}
	}
	return result;
}
 
Example #13
Source File: StatelessSessionImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void refresh(String entityName, Object entity, LockMode lockMode) {
		final EntityPersister persister = this.getEntityPersister( entityName, entity );
		final Serializable id = persister.getIdentifier( entity, getEntityMode() );
		if ( log.isTraceEnabled() ) {
			log.trace(
					"refreshing transient " +
					MessageHelper.infoString( persister, id, this.getFactory() )
			);
		}
		// TODO : can this ever happen???
//		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() )
//			);
//		}

		if ( persister.hasCache() ) {
			final CacheKey ck = new CacheKey(
					id,
			        persister.getIdentifierType(),
			        persister.getRootEntityName(),
			        this.getEntityMode(),
			        this.getFactory()
			);
			persister.getCache().remove(ck);
		}

		String previousFetchProfile = this.getFetchProfile();
		Object result = null;
		try {
			this.setFetchProfile( "refresh" );
			result = persister.load( id, entity, lockMode, this );
		}
		finally {
			this.setFetchProfile( previousFetchProfile );
		}
		UnresolvableObjectException.throwIfNull( result, id, persister.getEntityName() );
	}