public String getIdentifierPropertyName(String className) throws MappingException { return getMetamodel().entityPersister( className ).getIdentifierPropertyName(); }
/** * @param sessionFactory Session factory. * @param entityName Entity name. * * @return List of property names representing entity identifier. */ private static List<String> identifierPropertyNames(SessionFactoryImplementor sessionFactory, String entityName) { final String identifierPropertyName = sessionFactory.getMetamodel().entityPersister( entityName ).getIdentifierPropertyName(); if ( identifierPropertyName != null ) { // Single id. return Arrays.asList( identifierPropertyName ); } final Type identifierType = sessionFactory.getMetamodel().entityPersister( entityName ).getIdentifierType(); if ( identifierType instanceof EmbeddedComponentType ) { // Multiple ids. final EmbeddedComponentType embeddedComponentType = (EmbeddedComponentType) identifierType; return Arrays.asList( embeddedComponentType.getPropertyNames() ); } return Collections.emptyList(); } }
entityPersister.getIdentifierPropertyName(), entityPersister.getIdentifierType().toLoggableString( entityPersister.getIdentifier( entity ),
final String identifierPropertyName = sessionFactory.getMetamodel().entityPersister( entityName ).getIdentifierPropertyName(); propertyName = enversService.getAuditEntitiesConfiguration().getOriginalIdPropName() + "." + identifierPropertyName;
if ( persister != null && propertyName.equals( propertyPath ) && propertyName.equals( persister.getIdentifierPropertyName() ) ) { type = persister.getIdentifierType();
public String[] getIdentifierPropertyNames() { if ( getEntityPersister() != null ) { String identifierPropertyName = getEntityPersister().getIdentifierPropertyName(); if ( identifierPropertyName != null ) { return new String[] { identifierPropertyName }; } else { final IdentifierProperty identifierProperty = getEntityPersister().getEntityMetamodel() .getIdentifierProperty(); if ( identifierProperty.hasIdentifierMapper() && !identifierProperty.isEmbedded() ) { return new String[] { PropertyPath.IDENTIFIER_MAPPER_PROPERTY }; } else { if ( EmbeddedComponentType.class.isInstance( identifierProperty.getType() ) ) { return ( (EmbeddedComponentType) identifierProperty.getType() ).getPropertyNames(); } } } } return new String[] { EntityPersister.ENTITY_ID }; } }
@Override public ExpandingCompositeQuerySpace makeCompositeIdentifierQuerySpace() { final String compositeQuerySpaceUid = getUid() + "-id"; final ExpandingCompositeQuerySpace rhs = getExpandingQuerySpaces().makeCompositeQuerySpace( compositeQuerySpaceUid, new CompositePropertyMapping( (CompositeType) getEntityPersister().getIdentifierType(), (PropertyMapping) getEntityPersister(), getEntityPersister().getIdentifierPropertyName() ), canJoinsBeRequired() ); final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin( this, EntityPersister.ENTITY_ID, rhs, canJoinsBeRequired(), (CompositeType) persister.getIdentifierType() ); internalGetJoins().add( join ); return rhs; } }
@Override public String getIdPropertyName() { return this.entityPersister.getIdentifierPropertyName(); }
@Override public String getIdentifierPropertyName() { return persister.getIdentifierPropertyName(); }
public String getIdentifierPropertyName(String className) throws MappingException { return getEntityPersister(className).getIdentifierPropertyName(); }
public String getIdentifierPropertyName(String className) throws MappingException { return getEntityPersister(className).getIdentifierPropertyName(); }
public String getIdentifierPropertyName(String className) throws MappingException { return getEntityPersister(className).getIdentifierPropertyName(); }
public String getIdentifierPropertyName(String className) throws MappingException { return getEntityPersister(className).getIdentifierPropertyName(); }
private static IdOrder createIdOrder(EntityPersister entityPersister) { final String identifierPropertyName = entityPersister.getIdentifierPropertyName(); final Type identifierType = entityPersister.getIdentifierType(); if ( identifierType instanceof ComponentType ) { final ComponentType componentType = (ComponentType) identifierType; return new CompositeIdOrder( identifierPropertyName, componentType ); } else { return new SingularIdOrder( identifierPropertyName ); } }
entityPersister.getIdentifierPropertyName(), entityPersister.getIdentifierType().toLoggableString( entityPersister.getIdentifier( entity ), factory ) );
/** * Returns the type of a property, given it's name (the last part) and the full path. * * @param propertyName The last part of the full path to the property. * @return The type. * @0param propertyPath The full property path. */ public Type getPropertyType(String propertyName, String propertyPath) { checkInitialized(); Type type = null; // If this is an entity and the property is the identifier property, then use getIdentifierType(). // Note that the propertyName.equals( propertyPath ) checks whether we have a component // key reference, where the component class property name is the same as the // entity id property name; if the two are not equal, this is the case and // we'd need to "fall through" to using the property mapping. if ( persister != null && propertyName.equals( propertyPath ) && propertyName.equals( persister.getIdentifierPropertyName() ) ) { type = persister.getIdentifierType(); } else { // Otherwise, use the property mapping. PropertyMapping mapping = getPropertyMapping( propertyName ); type = mapping.toType( propertyPath ); } if ( type == null ) { throw new MappingException( "Property " + propertyName + " does not exist in " + ( ( queryableCollection == null ) ? "class" : "collection" ) + " " + ( ( queryableCollection == null ) ? fromElement.getClassName() : queryableCollection.getRole() ) ); } return type; }
/** * Returns the type of a property, given it's name (the last part) and the full path. * * @param propertyName The last part of the full path to the property. * @return The type. * @0param propertyPath The full property path. */ public Type getPropertyType(String propertyName, String propertyPath) { checkInitialized(); Type type = null; // If this is an entity and the property is the identifier property, then use getIdentifierType(). // Note that the propertyName.equals( propertyPath ) checks whether we have a component // key reference, where the component class property name is the same as the // entity id property name; if the two are not equal, this is the case and // we'd need to "fall through" to using the property mapping. if ( persister != null && propertyName.equals( propertyPath ) && propertyName.equals( persister.getIdentifierPropertyName() ) ) { type = persister.getIdentifierType(); } else { // Otherwise, use the property mapping. PropertyMapping mapping = getPropertyMapping( propertyName ); type = mapping.toType( propertyPath ); } if ( type == null ) { throw new MappingException( "Property " + propertyName + " does not exist in " + ( ( queryableCollection == null ) ? "class" : "collection" ) + " " + ( ( queryableCollection == null ) ? fromElement.getClassName() : queryableCollection.getRole() ) ); } return type; }
/** * Returns the type of a property, given it's name (the last part) and the full path. * * @param propertyName The last part of the full path to the property. * @return The type. * @0param propertyPath The full property path. */ public Type getPropertyType(String propertyName, String propertyPath) { checkInitialized(); Type type = null; // If this is an entity and the property is the identifier property, then use getIdentifierType(). // Note that the propertyName.equals( propertyPath ) checks whether we have a component // key reference, where the component class property name is the same as the // entity id property name; if the two are not equal, this is the case and // we'd need to "fall through" to using the property mapping. if ( persister != null && propertyName.equals( propertyPath ) && propertyName.equals( persister.getIdentifierPropertyName() ) ) { type = persister.getIdentifierType(); } else { // Otherwise, use the property mapping. PropertyMapping mapping = getPropertyMapping( propertyName ); type = mapping.toType( propertyPath ); } if ( type == null ) { throw new MappingException( "Property " + propertyName + " does not exist in " + ( ( queryableCollection == null ) ? "class" : "collection" ) + " " + ( ( queryableCollection == null ) ? fromElement.getClassName() : queryableCollection.getRole() ) ); } return type; }
public String getIdentityColumn() { checkInitialized(); String table = getTableAlias(); if ( table == null ) { throw new IllegalStateException( "No table alias for node " + this ); } String[] cols; String propertyName; if ( getEntityPersister() != null && getEntityPersister().getEntityMetamodel() != null && getEntityPersister().getEntityMetamodel().hasNonIdentifierPropertyNamedId() ) { propertyName = getEntityPersister().getIdentifierPropertyName(); } else { propertyName = EntityPersister.ENTITY_ID; } if ( getWalker().getStatementType() == HqlSqlTokenTypes.SELECT ) { cols = getPropertyMapping( propertyName ).toColumns( table, propertyName ); } else { cols = getPropertyMapping( propertyName ).toColumns( propertyName ); } String result = StringHelper.join( ", ", cols ); return cols.length == 1 ? result : "(" + result + ")"; }
public String getIdentityColumn() { checkInitialized(); String table = getTableAlias(); if ( table == null ) { throw new IllegalStateException( "No table alias for node " + this ); } String[] cols; String propertyName; if ( getEntityPersister() != null && getEntityPersister().getEntityMetamodel() != null && getEntityPersister().getEntityMetamodel().hasNonIdentifierPropertyNamedId() ) { propertyName = getEntityPersister().getIdentifierPropertyName(); } else { propertyName = EntityPersister.ENTITY_ID; } if ( getWalker().getStatementType() == HqlSqlTokenTypes.SELECT ) { cols = getPropertyMapping( propertyName ).toColumns( table, propertyName ); } else { cols = getPropertyMapping( propertyName ).toColumns( propertyName ); } String result = StringHelper.join( ", ", cols ); return cols.length == 1 ? result : "(" + result + ")"; }