Java Code Examples for org.hibernate.type.CompositeType#getPropertyNames()
The following examples show how to use
org.hibernate.type.CompositeType#getPropertyNames() .
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: Example.java From lams with GNU General Public License v2.0 | 6 votes |
protected void addComponentTypedValues( String path, Object component, CompositeType type, List<TypedValue> list, Criteria criteria, CriteriaQuery criteriaQuery) { if ( component != null ) { final String[] propertyNames = type.getPropertyNames(); final Type[] subtypes = type.getSubtypes(); final Object[] values = type.getPropertyValues( component, getEntityMode( criteria, criteriaQuery ) ); for ( int i=0; i<propertyNames.length; i++ ) { final Object value = values[i]; final Type subtype = subtypes[i]; final String subpath = StringHelper.qualify( path, propertyNames[i] ); if ( isPropertyIncluded( value, subpath, subtype ) ) { if ( subtype.isComponentType() ) { addComponentTypedValues( subpath, value, (CompositeType) subtype, list, criteria, criteriaQuery ); } else { addPropertyTypedValue( value, subtype, list ); } } } } }
Example 2
Source File: AbstractCollectionPersister.java From lams with GNU General Public License v2.0 | 6 votes |
private void initCollectionPropertyMap(String aliasName, Type type, String[] columnAliases, String[] columnNames) { collectionPropertyColumnAliases.put( aliasName, columnAliases ); collectionPropertyColumnNames.put( aliasName, columnNames ); if ( type.isComponentType() ) { CompositeType ct = (CompositeType) type; String[] propertyNames = ct.getPropertyNames(); for ( int i = 0; i < propertyNames.length; i++ ) { String name = propertyNames[i]; collectionPropertyColumnAliases.put( aliasName + "." + name, columnAliases[i] ); collectionPropertyColumnNames.put( aliasName + "." + name, columnNames[i] ); } } }
Example 3
Source File: Example.java From lams with GNU General Public License v2.0 | 5 votes |
protected void appendComponentCondition( String path, Object component, CompositeType type, Criteria criteria, CriteriaQuery criteriaQuery, StringBuilder buf) { if ( component != null ) { final String[] propertyNames = type.getPropertyNames(); final Object[] values = type.getPropertyValues( component, getEntityMode( criteria, criteriaQuery ) ); final Type[] subtypes = type.getSubtypes(); for ( int i=0; i<propertyNames.length; i++ ) { final String subPath = StringHelper.qualify( path, propertyNames[i] ); final Object value = values[i]; if ( isPropertyIncluded( value, subPath, subtypes[i] ) ) { final Type subtype = subtypes[i]; if ( subtype.isComponentType() ) { appendComponentCondition( subPath, value, (CompositeType) subtype, criteria, criteriaQuery, buf ); } else { appendPropertyCondition( subPath, value, criteria, criteriaQuery, buf ); } } } } }
Example 4
Source File: ComponentCollectionCriteriaInfoProvider.java From lams with GNU General Public License v2.0 | 5 votes |
ComponentCollectionCriteriaInfoProvider(QueryableCollection persister) { this.persister = persister; if ( !persister.getElementType().isComponentType() ) { throw new IllegalArgumentException( "persister for role " + persister.getRole() + " is not a collection-of-component" ); } CompositeType componentType = (CompositeType) persister.getElementType(); String[] names = componentType.getPropertyNames(); Type[] types = componentType.getSubtypes(); for ( int i = 0; i < names.length; i++ ) { subTypes.put( names[i], types[i] ); } }
Example 5
Source File: Cascade.java From lams with GNU General Public License v2.0 | 5 votes |
private static void cascadeComponent( final CascadingAction action, final CascadePoint cascadePoint, final EventSource eventSource, final int componentPathStackDepth, final Object parent, final Object child, final CompositeType componentType, final Object anything) { Object[] children = null; final Type[] types = componentType.getSubtypes(); final String[] propertyNames = componentType.getPropertyNames(); for ( int i = 0; i < types.length; i++ ) { final CascadeStyle componentPropertyStyle = componentType.getCascadeStyle( i ); final String subPropertyName = propertyNames[i]; if ( componentPropertyStyle.doCascade( action ) ) { if (children == null) { // Get children on demand. children = componentType.getPropertyValues( child, eventSource ); } cascadeProperty( action, cascadePoint, eventSource, componentPathStackDepth + 1, parent, children[i], types[i], componentPropertyStyle, subPropertyName, anything, false ); } } }
Example 6
Source File: Nullability.java From lams with GNU General Public License v2.0 | 5 votes |
/** * check component nullability. Returns property path that break * nullability or null if none * * @param value component properties * @param compositeType component not-nullable type * * @return property path * @throws HibernateException error while getting subcomponent values */ private String checkComponentNullability(Object value, CompositeType compositeType) throws HibernateException { // IMPL NOTE : we currently skip checking "any" and "many to any" mappings. // // This is not the best solution. But atm there is a mismatch between AnyType#getPropertyNullability // and the fact that cascaded-saves for "many to any" mappings are not performed until after this nullability // check. So the nullability check fails for transient entity elements with generated identifiers because // the identifier is not yet generated/assigned (is null) // // The more correct fix would be to cascade saves of the many-to-any elements before the Nullability checking if ( compositeType.isAnyType() ) { return null; } final boolean[] nullability = compositeType.getPropertyNullability(); if ( nullability != null ) { //do the test final Object[] subValues = compositeType.getPropertyValues( value, session ); final Type[] propertyTypes = compositeType.getSubtypes(); for ( int i = 0; i < subValues.length; i++ ) { final Object subValue = subValues[i]; if ( !nullability[i] && subValue==null ) { return compositeType.getPropertyNames()[i]; } else if ( subValue != null ) { final String breakProperties = checkSubElementsNullability( propertyTypes[i], subValue ); if ( breakProperties != null ) { return buildPropertyPath( compositeType.getPropertyNames()[i], breakProperties ); } } } } return null; }
Example 7
Source File: AbstractEntityPersister.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Must be called by subclasses, at the end of their constructors */ protected void initSubclassPropertyAliasesMap(PersistentClass model) throws MappingException { // ALIASES internalInitSubclassPropertyAliasesMap( null, model.getSubclassPropertyClosureIterator() ); // aliases for identifier ( alias.id ); skip if the entity defines a non-id property named 'id' if ( !entityMetamodel.hasNonIdentifierPropertyNamedId() ) { subclassPropertyAliases.put( ENTITY_ID, getIdentifierAliases() ); subclassPropertyColumnNames.put( ENTITY_ID, getIdentifierColumnNames() ); } // aliases named identifier ( alias.idname ) if ( hasIdentifierProperty() ) { subclassPropertyAliases.put( getIdentifierPropertyName(), getIdentifierAliases() ); subclassPropertyColumnNames.put( getIdentifierPropertyName(), getIdentifierColumnNames() ); } // aliases for composite-id's if ( getIdentifierType().isComponentType() ) { // Fetch embedded identifiers propertynames from the "virtual" identifier component CompositeType componentId = (CompositeType) getIdentifierType(); String[] idPropertyNames = componentId.getPropertyNames(); String[] idAliases = getIdentifierAliases(); String[] idColumnNames = getIdentifierColumnNames(); for ( int i = 0; i < idPropertyNames.length; i++ ) { if ( entityMetamodel.hasNonIdentifierPropertyNamedId() ) { subclassPropertyAliases.put( ENTITY_ID + "." + idPropertyNames[i], new String[] {idAliases[i]} ); subclassPropertyColumnNames.put( ENTITY_ID + "." + getIdentifierPropertyName() + "." + idPropertyNames[i], new String[] {idColumnNames[i]} ); } // if (hasIdentifierProperty() && !ENTITY_ID.equals( getIdentifierPropertyName() ) ) { if ( hasIdentifierProperty() ) { subclassPropertyAliases.put( getIdentifierPropertyName() + "." + idPropertyNames[i], new String[] {idAliases[i]} ); subclassPropertyColumnNames.put( getIdentifierPropertyName() + "." + idPropertyNames[i], new String[] {idColumnNames[i]} ); } else { // embedded composite ids ( alias.idname1, alias.idname2 ) subclassPropertyAliases.put( idPropertyNames[i], new String[] {idAliases[i]} ); subclassPropertyColumnNames.put( idPropertyNames[i], new String[] {idColumnNames[i]} ); } } } if ( entityMetamodel.isPolymorphic() ) { subclassPropertyAliases.put( ENTITY_CLASS, new String[] {getDiscriminatorAlias()} ); subclassPropertyColumnNames.put( ENTITY_CLASS, new String[] {getDiscriminatorColumnName()} ); } }
Example 8
Source File: ForeignKeys.java From lams with GNU General Public License v2.0 | 4 votes |
private static void collectNonNullableTransientEntities( Nullifier nullifier, Object value, String propertyName, Type type, boolean isNullable, SharedSessionContractImplementor session, NonNullableTransientDependencies nonNullableTransientEntities) { if ( value == null ) { return; } if ( type.isEntityType() ) { final EntityType entityType = (EntityType) type; if ( !isNullable && !entityType.isOneToOne() && nullifier.isNullifiable( entityType.getAssociatedEntityName(), value ) ) { nonNullableTransientEntities.add( propertyName, value ); } } else if ( type.isAnyType() ) { if ( !isNullable && nullifier.isNullifiable( null, value ) ) { nonNullableTransientEntities.add( propertyName, value ); } } else if ( type.isComponentType() ) { final CompositeType actype = (CompositeType) type; final boolean[] subValueNullability = actype.getPropertyNullability(); if ( subValueNullability != null ) { final String[] subPropertyNames = actype.getPropertyNames(); final Object[] subvalues = actype.getPropertyValues( value, session ); final Type[] subtypes = actype.getSubtypes(); for ( int j = 0; j < subvalues.length; j++ ) { collectNonNullableTransientEntities( nullifier, subvalues[j], subPropertyNames[j], subtypes[j], subValueNullability[j], session, nonNullableTransientEntities ); } } } }