/** * Retrieves the defined entity-names for any subclasses defined for this * entity. * * @return Any subclass entity-names. */ protected Set getSubclassEntityNames() { return entityMetamodel.getSubclassEntityNames(); }
public IdentifierGenerator getIdentifierGenerator() throws HibernateException { return entityMetamodel.getIdentifierProperty().getIdentifierGenerator(); }
private void collectAttributeDefinitions( Map<String, AttributeDefinition> attributeDefinitionsByName, EntityMetamodel metamodel) { for ( int i = 0; i < metamodel.getPropertySpan(); i++ ) { final AttributeDefinition attributeDefinition = metamodel.getProperties()[i]; LOG.tracef( "Ignoring subclass attribute definition [%s.%s] because it is defined in a superclass ", entityMetamodel.getName(), attributeDefinition.getName() ); final Set<String> subClassEntityNames = metamodel.getSubclassEntityNames(); if ( subClassEntityNames == null ) { return; if ( metamodel.getName().equals( subClassEntityName ) ) { "Could not locate subclass EntityPersister [%s] while processing EntityPersister [%s]", subClassEntityName, metamodel.getName() ),
@Override public void setPropertyValues(Object entity, Object[] values) throws HibernateException { boolean setAll = !entityMetamodel.hasLazyProperties(); for ( int j = 0; j < entityMetamodel.getPropertySpan(); j++ ) { if ( setAll || values[j] != LazyPropertyInitializer.UNFETCHED_PROPERTY ) { setters[j].set( entity, values[j], getFactory() ); } } }
@Override public Object[] getPropertyValues(Object entity) { final BytecodeEnhancementMetadata enhancementMetadata = entityMetamodel.getBytecodeEnhancementMetadata(); final int span = entityMetamodel.getPropertySpan(); final Object[] result = new Object[span]; for ( int j = 0; j < span; j++ ) { NonIdentifierAttribute property = entityMetamodel.getProperties()[j]; if ( !property.isLazy() || enhancementMetadata.isAttributeLoaded( entity, property.getName() ) ) { result[j] = getters[j].get( entity ); } else { result[j] = LazyPropertyInitializer.UNFETCHED_PROPERTY; } } return result; }
: propertyPath; Integer index = entityMetamodel.getPropertyIndexOrNull( basePropertyName ); if ( index == null ) { propertyPath = PropertyPath.IDENTIFIER_MAPPER_PROPERTY + "." + propertyPath; : propertyPath; index = entityMetamodel.getPropertyIndexOrNull( basePropertyName ); final Object baseValue = getPropertyValue( entity, index ); if ( loc > 0 ) { (ComponentType) entityMetamodel.getPropertyTypes()[index], baseValue, propertyPath.substring( loc + 1 )
this.entityMetamodel = entityMetamodel; if ( !entityMetamodel.getIdentifierProperty().isVirtual() ) { idGetter = buildPropertyGetter( mappingInfo.getIdentifierProperty(), mappingInfo ); idSetter = buildPropertySetter( mappingInfo.getIdentifierProperty(), mappingInfo ); propertySpan = entityMetamodel.getPropertySpan(); if ( entityMetamodel.isLazy() && !entityMetamodel.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading() ) { proxyFactory = buildProxyFactory( mappingInfo, idGetter, idSetter ); if ( proxyFactory == null ) { entityMetamodel.setLazy( false ); getEntityName(), getFactory(), (ComponentType) entityMetamodel.getIdentifierProperty().getType(), (ComponentType) identifierMapperType );
/** * Locate the property-indices of all properties considered to be dirty. * * @param currentState The current state of the entity (the state to be checked). * @param previousState The previous state of the entity (the state to be checked against). * @param entity The entity for which we are checking state dirtiness. * @param session The session in which the check is occurring. * * @return <tt>null</tt> or the indices of the dirty properties * * @throws HibernateException */ public int[] findDirty(Object[] currentState, Object[] previousState, Object entity, SharedSessionContractImplementor session) throws HibernateException { int[] props = TypeHelper.findDirty( entityMetamodel.getProperties(), currentState, previousState, propertyColumnUpdateable, session ); if ( props == null ) { return null; } else { logDirtyProperties( props ); return props; } }
public int getPropertyIndex(String propertyName) { return entityMetamodel.getPropertyIndex( propertyName ); }
@Override public int[] resolveAttributeIndexes(String[] attributeNames) { if ( attributeNames == null || attributeNames.length == 0 ) { return new int[0]; } int[] fields = new int[attributeNames.length]; int counter = 0; // We sort to get rid of duplicates Arrays.sort( attributeNames ); Integer index0 = entityMetamodel.getPropertyIndexOrNull( attributeNames[0] ); if ( index0 != null ) { fields[counter++] = index0; } for ( int i = 0, j = 1; j < attributeNames.length; ++i, ++j ) { if ( !attributeNames[i].equals( attributeNames[j] ) ) { Integer index = entityMetamodel.getPropertyIndexOrNull( attributeNames[j] ); if ( index != null ) { fields[counter++] = index; } } } return Arrays.copyOf( fields, counter ); }
this.entityMetamodel = new EntityMetamodel( persistentClass, this, factory ); this.entityTuplizer = this.entityMetamodel.getTuplizer(); if ( entityMetamodel.isMutable() ) { this.entityEntryFactory = MutableEntityEntryFactory.INSTANCE; int hydrateSpan = entityMetamodel.getPropertySpan(); propertyColumnSpans = new int[hydrateSpan]; propertySubclassNames = new String[hydrateSpan]; if ( entityMetamodel.isMutable() ) { refCacheEntries = false;
@Override public Member resolveMember(AttributeContext attributeContext) { final AbstractIdentifiableType identifiableType = (AbstractIdentifiableType) attributeContext.getOwnerType(); final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType ); if ( !attributeContext.getPropertyMapping().getName() .equals( entityMetamodel.getIdentifierProperty().getName() ) ) { // this *should* indicate processing part of an IdClass... return virtualIdentifierMemberResolver.resolveMember( attributeContext ); } final Getter getter = entityMetamodel.getTuplizer().getIdentifierGetter(); if ( PropertyAccessMapImpl.GetterImpl.class.isInstance( getter ) ) { return new MapMember( entityMetamodel.getIdentifierProperty().getName(), entityMetamodel.getIdentifierProperty().getType().getReturnedClass() ); } else { return getter.getMember(); } } };
public Object[] getPropertyValues(Object entity) throws HibernateException { boolean getAll = shouldGetAllProperties( entity ); final int span = entityMetamodel.getPropertySpan(); final Object[] result = new Object[span]; for ( int j = 0; j < span; j++ ) { StandardProperty property = entityMetamodel.getProperties()[j]; if ( getAll || !property.isLazy() ) { result[j] = getters[j].get( entity ); } else { result[j] = LazyPropertyInitializer.UNFETCHED_PROPERTY; } } return result; }
public String[] getPropertyNames() { return entityMetamodel.getPropertyNames(); }
@Test public void testTypeSelection() { int index = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getPropertyIndex( "theBytes" ); Type type = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getProperties()[index].getType(); assertEquals( MaterializedBlobType.INSTANCE, type ); }
protected interface InclusionChecker { boolean includeProperty(int propertyNumber); }
public Object createProxy(Serializable id, SharedSessionContractImplementor session) throws HibernateException { return entityMetamodel.getTuplizer().createProxy( id, session ); }
@Override public boolean isDeleteCascaded(ManagedType<?> ownerType, String attributeName) { AbstractEntityPersister entityPersister = getEntityPersister(ownerType); if (entityPersister != null) { EntityMetamodel entityMetamodel = entityPersister.getEntityMetamodel(); Integer index = entityMetamodel.getPropertyIndexOrNull(attributeName); if (index != null) { return entityMetamodel.getCascadeStyles()[index].doCascade(CascadingAction.DELETE); } } return false; }
String propertyName = role.substring(lastDotIndex + 1); EntityMetamodel entityMetamodel = this.factory.getEntityPersister(entityName).getEntityMetamodel(); int propertyIndex = entityMetamodel.getPropertyIndex(propertyName); if (entityMetamodel.getPropertyTypes()[propertyIndex] instanceof ManyToOneType) { boolean nullable = entityMetamodel.getPropertyNullability()[propertyIndex]; if (!nullable) { continue;
@Override public Member resolveMember(AttributeContext attributeContext) { final AbstractIdentifiableType identifiableType = (AbstractIdentifiableType) attributeContext.getOwnerType(); final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType ); final String versionPropertyName = attributeContext.getPropertyMapping().getName(); if ( !versionPropertyName.equals( entityMetamodel.getVersionProperty().getName() ) ) { // this should never happen, but to be safe... throw new IllegalArgumentException( "Given property did not match declared version property" ); } final Getter getter = entityMetamodel.getTuplizer().getVersionGetter(); if ( PropertyAccessMapImpl.GetterImpl.class.isInstance( getter ) ) { return new MapMember( versionPropertyName, attributeContext.getPropertyMapping().getType().getReturnedClass() ); } else { return getter.getMember(); } } };