@Override public boolean isLoaded(Object entity, String attributeName) { LoadState state = PersistenceUtilHelper.isLoadedWithoutReference(entity, attributeName, this.cache); if (state == LoadState.LOADED) { return true; } if (state == LoadState.NOT_LOADED) { return false; } return (PersistenceUtilHelper.isLoadedWithReference(entity, attributeName, this.cache) != LoadState.NOT_LOADED); }
/** * If the provider determines that the entity has been provided by itself * and that the state of the specified attribute has been loaded, this * method returns LoadState.LOADED. If the provider determines that the * entity has been provided by itself and that either entity attributes with * FetchType EAGER have not been loaded or that the state of the specified * attribute has not been loaded, this methods returns LoadState.NOT_LOADED. * If a provider cannot determine the load state, this method returns * LoadState.UNKNOWN. The provider's implementation of this method must not * obtain a reference to an attribute value, as this could trigger the * loading of entity state if the entity has been provided by a different * provider. * * @param entity * @param attributeName * name of attribute whose load status is to be determined * @return load status of the attribute */ @Override public LoadState isLoadedWithoutReference(Object paramObject, String paramString) { return PersistenceUtilHelper.isLoadedWithoutReference(paramObject, paramString, provider.getCache()); }
@Override public boolean isLoaded(Object entity) { return (PersistenceUtilHelper.isLoaded(entity) != LoadState.NOT_LOADED); }
/** * If the provider determines that the entity has been provided by itself * and that the state of the specified attribute has been loaded, this * method returns LoadState.LOADED. If a provider determines that the entity * has been provided by itself and that either the entity attributes with * FetchType EAGER have not been loaded or that the state of the specified * attribute has not been loaded, this method returns LoadState.NOT_LOADED. * If the provider cannot determine the load state, this method returns * LoadState.UNKNOWN. The provider's implementation of this method is * permitted to obtain a reference to the attribute value. (This access is * safe because providers which might trigger the loading of the attribute * state will have already been determined by isLoadedWithoutReference. ) * * @param entity * @param attributeName * name of attribute whose load status is to be determined * @return load status of the attribute */ @Override public LoadState isLoadedWithReference(Object paramObject, String paramString) { return PersistenceUtilHelper.isLoadedWithReference(paramObject, paramString, provider.getCache()); }
@Test public void testisLoadedWithoutReferenceAsNull() { LoadState state = PersistenceUtilHelper.isLoadedWithoutReference(null, null, cache); Assert.assertNotNull(state); Assert.assertEquals(LoadState.NOT_LOADED, state); }
@Override public boolean isLoaded(Object entity) { return (PersistenceUtilHelper.isLoaded(entity) != LoadState.NOT_LOADED); }
@Test public void testisLoadedWithReferenceAsNull() { LoadState state = PersistenceUtilHelper.isLoadedWithReference(null, null, cache); Assert.assertNotNull(state); Assert.assertEquals(LoadState.NOT_LOADED, state); }
@Override public boolean isLoaded(Object entity, String attributeName) { LoadState state = PersistenceUtilHelper.isLoadedWithoutReference(entity, attributeName, this.cache); if (state == LoadState.LOADED) { return true; } if (state == LoadState.NOT_LOADED) { return false; } return (PersistenceUtilHelper.isLoadedWithReference(entity, attributeName, this.cache) != LoadState.NOT_LOADED); }
@Test public void testisLoadedWithOutReferenceAsKunderaProxy() throws NoSuchMethodException, SecurityException { CglibLazyInitializerFactory factory = new CglibLazyInitializerFactory(); KunderaProxy proxy = factory.getProxy("Person", Person.class, Person.class.getDeclaredMethod("getPersonId", null), Person.class.getDeclaredMethod("setPersonId", String.class), "personId", null); LoadState state = PersistenceUtilHelper.isLoadedWithoutReference(proxy, "personName", cache); Assert.assertNotNull(state); Assert.assertEquals(LoadState.NOT_LOADED, state); // factory. }
/** * If the provider determines that the entity has been provided by itself * and that the state of all attributes for which FetchType EAGER has been * specified have been loaded, this method returns LoadState.LOADED. If the * provider determines that the entity has been provided by itself and that * not all attributes with FetchType EAGER have been loaded, this method * returns LoadState.NOT_LOADED. If the provider cannot determine if the * entity has been provided by itself, this method returns * LoadState.UNKNOWN. The provider's implementation of this method must not * obtain a reference to any attribute value, as this could trigger the * loading of entity state if the entity has been provided by a different * provider. * * @param entity * whose loaded status is to be determined * @return load status of the entity */ @Override public LoadState isLoaded(Object paramObject) { return PersistenceUtilHelper.isLoaded(paramObject); }
@Test public void testisLoadedWithReferenceAsKunderaProxy() throws NoSuchMethodException, SecurityException { CglibLazyInitializerFactory factory = new CglibLazyInitializerFactory(); KunderaProxy proxy = factory.getProxy("Person", Person.class, Person.class.getDeclaredMethod("getPersonId", null), Person.class.getDeclaredMethod("setPersonId", String.class), "personId", null); LoadState state = PersistenceUtilHelper.isLoadedWithReference(proxy, "personId", cache); Assert.assertNotNull(state); Assert.assertEquals(LoadState.UNKNOWN, state); }
@Test public void testisLoadedWithoutReferenceAsLoad() { Person p = new Person(); p.setPersonName("Vivek"); LoadState state = PersistenceUtilHelper.isLoadedWithoutReference(p, "personName", cache); Assert.assertNotNull(state); Assert.assertEquals(LoadState.LOADED, state); }
@Test public void testisLoadedWAsKunderaProxy() throws NoSuchMethodException, SecurityException { CglibLazyInitializerFactory factory = new CglibLazyInitializerFactory(); KunderaProxy proxy = factory.getProxy("Person", Person.class, Person.class.getDeclaredMethod("getPersonId", null), Person.class.getDeclaredMethod("setPersonId", String.class), "personId", null); LoadState state = PersistenceUtilHelper.isLoaded(proxy); Assert.assertNotNull(state); Assert.assertEquals(LoadState.NOT_LOADED, state); // factory. }
@Test public void testisLoadedWithReferenceAsLoaded() { Person p = new Person(); p.setPersonName("Vivek"); LoadState state = PersistenceUtilHelper.isLoadedWithReference(p, "personName", cache); Assert.assertNotNull(state); Assert.assertEquals(LoadState.UNKNOWN, state); }