@Override protected ProxyFactory buildProxyFactory( PersistentClass persistentClass, Getter idGetter, Setter idSetter) { return super.buildProxyFactory( persistentClass, idGetter, idSetter ); } }
if ( !proxyInterface.isInterface() ) { throw new MappingException( "proxy must be either an interface, or the class itself: " + getEntityName() ); ReflectHelper.getMethod( proxyInterface, idSetterMethod ); ProxyFactory pf = buildProxyFactoryInternal( persistentClass, idGetter, idSetter ); try { pf.postInstantiate( getEntityName(), mappedClass, proxyInterfaces, LOG.unableToCreateProxyFactory( getEntityName(), he ); pf = null;
@Override public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) { if ( entityInstance == null ) { return getEntityName(); } final Class concreteEntityClass = entityInstance.getClass(); if ( concreteEntityClass == getMappedClass() ) { return getEntityName(); } else { String entityName = getEntityMetamodel().findEntityNameByEntityClass( concreteEntityClass ); if ( entityName == null ) { throw new HibernateException( "Unable to resolve entity name from Class [" + concreteEntityClass.getName() + "]" + " expected instance/subclass of [" + getEntityName() + "]" ); } return entityName; } }
@Override public Object[] getPropertyValues(Object entity) throws HibernateException { if ( shouldGetAllProperties( entity ) && optimizer != null && optimizer.getAccessOptimizer() != null ) { return getPropertyValuesWithOptimizer( entity ); } else { return super.getPropertyValues( entity ); } }
@Override public void setPropertyValues(Object entity, Object[] values) throws HibernateException { if ( !getEntityMetamodel().hasLazyProperties() && optimizer != null && optimizer.getAccessOptimizer() != null ) { setPropertyValuesWithOptimizer( entity, values ); } else { super.setPropertyValues( entity, values ); } }
if ( ! proxyInterface.isInterface() ) { throw new MappingException( "proxy must be either an interface, or the class itself: " + getEntityName() ); Method method = getGetter( property ).getMethod(); if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { LOG.gettersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName()); method = getSetter( property ).getMethod(); if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { LOG.settersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName()); ReflectHelper.getMethod(proxyInterface, idSetterMethod); ProxyFactory pf = buildProxyFactoryInternal( entityBinding, idGetter, idSetter ); try { pf.postInstantiate( getEntityName(), mappedClass, proxyInterfaces, LOG.unableToCreateProxyFactory(getEntityName(), he); pf = null;
/** * {@inheritDoc} */ @Override public void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session) { if ( isInstrumented() ) { Set lazyProps = lazyPropertiesAreUnfetched && getEntityMetamodel().hasLazyProperties() ? lazyPropertyNames : null; //TODO: if we support multiple fetch groups, we would need // to clone the set of lazy properties! FieldInterceptionHelper.injectFieldInterceptor( entity, getEntityName(), lazyProps, session ); } }
@Override public void afterInitialize(Object entity, SharedSessionContractImplementor session) { // moving to multiple fetch groups, the idea of `lazyPropertiesAreUnfetched` really // needs to become either: // 1) the names of all un-fetched fetch groups // 2) the names of all fetched fetch groups // probably (2) is best // // ultimately this comes from EntityEntry, although usage-search seems to show it is never updated there. // // also org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyPropertiesFromDatastore() // needs to be re-worked if ( entity instanceof PersistentAttributeInterceptable ) { final LazyAttributeLoadingInterceptor interceptor = getEntityMetamodel().getBytecodeEnhancementMetadata().extractInterceptor( entity ); if ( interceptor == null ) { getEntityMetamodel().getBytecodeEnhancementMetadata().injectInterceptor( entity, session ); } else { if ( interceptor.getLinkedSession() == null ) { interceptor.setSession( session ); } } } // clear the fields that are marked as dirty in the dirtyness tracker if ( entity instanceof SelfDirtinessTracker ) { ( (SelfDirtinessTracker) entity ).$$_hibernate_clearDirtyAttributes(); } }
private Getter getGetter(AttributeBinding mappedProperty) throws PropertyNotFoundException, MappingException { return getPropertyAccessor( mappedProperty ).getGetter( mappedProperty.getContainer().getClassReference(), mappedProperty.getAttribute().getName() ); }
/** * {@inheritDoc} */ @Override protected Getter buildPropertyGetter(AttributeBinding mappedProperty) { return getGetter( mappedProperty ); }
@Override public Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SharedSessionContractImplementor session) { if ( shouldGetAllProperties( entity ) && optimizer != null && optimizer.getAccessOptimizer() != null ) { return getPropertyValuesWithOptimizer( entity ); } else { return super.getPropertyValuesToInsert( entity, mergeMap, session ); } }
if ( ! proxyInterface.isInterface() ) { throw new MappingException( "proxy must be either an interface, or the class itself: " + getEntityName() ); Method method = getGetter( property ).getMethod(); if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { LOG.gettersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName()); method = getSetter( property ).getMethod(); if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { LOG.settersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName()); ReflectHelper.getMethod(proxyInterface, idSetterMethod); ProxyFactory pf = buildProxyFactoryInternal( entityBinding, idGetter, idSetter ); try { pf.postInstantiate( getEntityName(), mappedClass, proxyInterfaces, LOG.unableToCreateProxyFactory(getEntityName(), he); pf = null;
/** * {@inheritDoc} */ @Override public void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session) { if ( isInstrumented() ) { Set lazyProps = lazyPropertiesAreUnfetched && getEntityMetamodel().hasLazyProperties() ? lazyPropertyNames : null; //TODO: if we support multiple fetch groups, we would need // to clone the set of lazy properties! FieldInterceptionHelper.injectFieldInterceptor( entity, getEntityName(), lazyProps, session ); } }
/** * {@inheritDoc} */ @Override public void setPropertyValues(Object entity, Object[] values) throws HibernateException { if ( !getEntityMetamodel().hasLazyProperties() && optimizer != null && optimizer.getAccessOptimizer() != null ) { setPropertyValuesWithOptimizer( entity, values ); } else { super.setPropertyValues( entity, values ); } }
/** * {@inheritDoc} */ @Override public boolean hasUninitializedLazyProperties(Object entity) { if ( getEntityMetamodel().hasLazyProperties() ) { FieldInterceptor callback = FieldInterceptionHelper.extractFieldInterceptor( entity ); return callback != null && !callback.isInitialized(); } else { return false; } }
private Getter getGetter(AttributeBinding mappedProperty) throws PropertyNotFoundException, MappingException { return getPropertyAccessor( mappedProperty ).getGetter( mappedProperty.getContainer().getClassReference(), mappedProperty.getAttribute().getName() ); }
/** * {@inheritDoc} */ @Override protected Getter buildPropertyGetter(AttributeBinding mappedProperty) { return getGetter( mappedProperty ); }
/** * {@inheritDoc} */ public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) { final Class concreteEntityClass = entityInstance.getClass(); if ( concreteEntityClass == getMappedClass() ) { return getEntityName(); } else { String entityName = getEntityMetamodel().findEntityNameByEntityClass( concreteEntityClass ); if ( entityName == null ) { throw new HibernateException( "Unable to resolve entity name from Class [" + concreteEntityClass.getName() + "]" + " expected instance/subclass of [" + getEntityName() + "]" ); } return entityName; } }
/** * {@inheritDoc} */ @Override public Object[] getPropertyValues(Object entity) throws HibernateException { if ( shouldGetAllProperties( entity ) && optimizer != null && optimizer.getAccessOptimizer() != null ) { return getPropertyValuesWithOptimizer( entity ); } else { return super.getPropertyValues( entity ); } }
/** * {@inheritDoc} */ @Override public void setPropertyValues(Object entity, Object[] values) throws HibernateException { if ( !getEntityMetamodel().hasLazyProperties() && optimizer != null && optimizer.getAccessOptimizer() != null ) { setPropertyValuesWithOptimizer( entity, values ); } else { super.setPropertyValues( entity, values ); } }