javax.persistence.spi.LoadState Java Examples
The following examples show how to use
javax.persistence.spi.LoadState.
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: Persistence.java From lams with GNU General Public License v2.0 | 6 votes |
public boolean isLoaded(Object entity) { PersistenceProviderResolver resolver = PersistenceProviderResolverHolder.getPersistenceProviderResolver(); List<PersistenceProvider> providers = resolver.getPersistenceProviders(); for (PersistenceProvider provider : providers) { LoadState loadstate = provider.getProviderUtil().isLoaded(entity); if(loadstate == LoadState.LOADED) { return true; } else if (loadstate == LoadState.NOT_LOADED) { return false; } // else continue } //None of the providers could determine the load state return true; }
Example #2
Source File: PersistenceUnitUtilImpl.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public boolean isLoaded(Object entity, String attributeName) { // added log message to help with HHH-7454, if state == LoadState,NOT_LOADED, returning true or false is not accurate. log.debug( "PersistenceUnitUtil#isLoaded is not always accurate; consider using EntityManager#contains instead" ); LoadState state = PersistenceUtilHelper.isLoadedWithoutReference( entity, attributeName, cache ); if ( state == LoadState.LOADED ) { return true; } else if ( state == LoadState.NOT_LOADED ) { return false; } else { return PersistenceUtilHelper.isLoadedWithReference( entity, attributeName, cache ) != LoadState.NOT_LOADED; } }
Example #3
Source File: PersistenceUtilHelper.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Is the given attribute (by name) loaded? This form must take care to not access the attribute (trigger * initialization). * * @param entity The entity * @param attributeName The name of the attribute to check * @param cache The cache we maintain of attribute resolutions * * @return The LoadState */ public static LoadState isLoadedWithReference(Object entity, String attributeName, MetadataCache cache) { if ( entity instanceof HibernateProxy ) { final LazyInitializer li = ( (HibernateProxy) entity ).getHibernateLazyInitializer(); if ( li.isUninitialized() ) { // we have an uninitialized proxy, the attribute cannot be loaded return LoadState.NOT_LOADED; } else { // swap the proxy with target (for proper class name resolution) entity = li.getImplementation(); } } try { final Class entityClass = entity.getClass(); final Object attributeValue = cache.getClassMetadata( entityClass ) .getAttributeAccess( attributeName ) .extractValue( entity ); return isLoaded( attributeValue ); } catch (AttributeExtractionException ignore) { return LoadState.UNKNOWN; } }
Example #4
Source File: ReactivePersistenceProvider.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override public LoadState isLoadedWithoutReference(Object proxy, String property) { return PersistenceUtilHelper.isLoadedWithoutReference( proxy, property, cache ); }
Example #5
Source File: ReactivePersistenceProvider.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override public LoadState isLoadedWithReference(Object proxy, String property) { return PersistenceUtilHelper.isLoadedWithReference( proxy, property, cache ); }
Example #6
Source File: ReactivePersistenceProvider.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override public LoadState isLoaded(Object o) { return PersistenceUtilHelper.isLoaded(o); }
Example #7
Source File: FastBootHibernatePersistenceProvider.java From quarkus with Apache License 2.0 | 4 votes |
@Override public LoadState isLoadedWithoutReference(Object proxy, String property) { return PersistenceUtilHelper.isLoadedWithoutReference(proxy, property, cache); }
Example #8
Source File: FastBootHibernatePersistenceProvider.java From quarkus with Apache License 2.0 | 4 votes |
@Override public LoadState isLoadedWithReference(Object proxy, String property) { return PersistenceUtilHelper.isLoadedWithReference(proxy, property, cache); }
Example #9
Source File: FastBootHibernatePersistenceProvider.java From quarkus with Apache License 2.0 | 4 votes |
@Override public LoadState isLoaded(Object o) { return PersistenceUtilHelper.isLoaded(o); }
Example #10
Source File: PersistenceUnitUtilImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public boolean isLoaded(Object entity) { // added log message to help with HHH-7454, if state == LoadState,NOT_LOADED, returning true or false is not accurate. log.debug( "PersistenceUnitUtil#isLoaded is not always accurate; consider using EntityManager#contains instead" ); return PersistenceUtilHelper.isLoaded( entity ) != LoadState.NOT_LOADED; }
Example #11
Source File: HibernatePersistenceProvider.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public LoadState isLoadedWithoutReference(Object proxy, String property) { return PersistenceUtilHelper.isLoadedWithoutReference( proxy, property, cache ); }
Example #12
Source File: HibernatePersistenceProvider.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public LoadState isLoadedWithReference(Object proxy, String property) { return PersistenceUtilHelper.isLoadedWithReference( proxy, property, cache ); }
Example #13
Source File: HibernatePersistenceProvider.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public LoadState isLoaded(Object o) { return PersistenceUtilHelper.isLoaded(o); }
Example #14
Source File: JpaPersistence.java From javamelody with Apache License 2.0 | 4 votes |
@Override public LoadState isLoadedWithoutReference(Object entity, String attributeName) { return LoadState.UNKNOWN; }
Example #15
Source File: JpaPersistence.java From javamelody with Apache License 2.0 | 4 votes |
@Override public LoadState isLoadedWithReference(Object entity, String attributeName) { return LoadState.UNKNOWN; }
Example #16
Source File: JpaPersistence.java From javamelody with Apache License 2.0 | 4 votes |
@Override public LoadState isLoaded(Object entity) { return LoadState.UNKNOWN; }