@PostConstruct public void init() throws ClassNotFoundException { final Configuration configuration = annotationSessionFactory .getConfiguration(); final ReflectionManager reflectionManager = configuration .getReflectionManager(); final Iterator<PersistentClass> classMappings = configuration .getClassMappings(); while (classMappings.hasNext()) { entityCallbackHandler.add(reflectionManager.classForName( classMappings.next().getClassName(), this.getClass()), reflectionManager); } }
private static void bindPojoRepresentation(Element node, PersistentClass entity, Mappings mappings, java.util.Map metaTags) { String className = getClassName( node.attribute( "name" ), mappings ); String proxyName = getClassName( node.attribute( "proxy" ), mappings ); entity.setClassName( className ); if ( proxyName != null ) { entity.setProxyInterfaceName( proxyName ); entity.setLazy( true ); } else if ( entity.isLazy() ) { entity.setProxyInterfaceName( className ); } Element tuplizer = locateTuplizerDefinition( node, EntityMode.POJO ); if ( tuplizer != null ) { entity.addTuplizer( EntityMode.POJO, tuplizer.attributeValue( "class" ) ); } }
private static String getClassTableName( PersistentClass model, Element node, String schema, String catalog, Table denormalizedSuperTable, Mappings mappings) { Attribute tableNameNode = node.attribute( "table" ); String logicalTableName; String physicalTableName; if ( tableNameNode == null ) { logicalTableName = StringHelper.unqualify( model.getEntityName() ); physicalTableName = getNamingStrategyDelegate( mappings ).determineImplicitPrimaryTableName( model.getEntityName(), model.getJpaEntityName() ); } else { logicalTableName = tableNameNode.getValue(); physicalTableName = getNamingStrategyDelegate( mappings ).toPhysicalTableName( logicalTableName ); } mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable ); return physicalTableName; }
public void doSecondPass(java.util.Map persistentClasses) throws MappingException { if ( value instanceof ManyToOne ) { ManyToOne manyToOne = (ManyToOne) value; PersistentClass ref = (PersistentClass) persistentClasses.get( manyToOne.getReferencedEntityName() ); if ( ref == null ) { throw new AnnotationException( "@OneToOne or @ManyToOne on " + StringHelper.qualify( entityClassName, path ) + " references an unknown entity: " + manyToOne.getReferencedEntityName() ); } BinderHelper.createSyntheticPropertyReference( columns, ref, null, manyToOne, false, mappings ); TableBinder.bindFk( ref, null, columns, manyToOne, unique, mappings ); /* * HbmMetadataSourceProcessorImpl does this only when property-ref != null, but IMO, it makes sense event if it is null */ if ( !manyToOne.isIgnoreNotFound() ) manyToOne.createPropertyRefConstraints( persistentClasses ); } else if ( value instanceof OneToOne ) { value.createForeignKey(); } else { throw new AssertionFailure( "FkSecondPass for a wrong value type: " + value.getClass().getName() ); } }
public void doSecondPass(Map persistentClasses) throws MappingException { org.hibernate.mapping.FetchProfile profile = mappings.findOrCreateFetchProfile( fetchProfileName, MetadataSource.ANNOTATIONS ); if ( MetadataSource.ANNOTATIONS != profile.getSource() ) { return; } PersistentClass clazz = mappings.getClass( fetch.entity().getName() ); // throws MappingException in case the property does not exist clazz.getProperty( fetch.association() ); profile.addFetch( fetch.entity().getName(), fetch.association(), fetch.mode().toString().toLowerCase() ); }
private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) { String alias = returnElem.attributeValue( "alias" ); if( StringHelper.isEmpty( alias )) { alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key. } String entityName = HbmBinder.getEntityName(returnElem, mappings); if(entityName==null) { throw new MappingException( "<return alias='" + alias + "'> must specify either a class or entity-name"); } LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) ); PersistentClass pc = mappings.getClass( entityName ); java.util.Map propertyResults = bindPropertyResults(alias, returnElem, pc, mappings ); return new NativeSQLQueryRootReturn( alias, entityName, propertyResults, lockMode ); }
private static void processIdPropertiesIfNotAlready( Map<XClass, InheritanceState> inheritanceStatePerClass, Mappings mappings, PersistentClass persistentClass, EntityBinder entityBinder, PropertyHolder propertyHolder, HashMap<String, IdGenerator> classGenerators, InheritanceState.ElementsToProcess elementsToProcess, boolean subclassAndSingleTableStrategy, Set<String> idPropertiesIfIdClass) { Set<String> missingIdProperties = new HashSet<String>( idPropertiesIfIdClass ); for ( PropertyData propertyAnnotatedElement : elementsToProcess.getElements() ) { String propertyName = propertyAnnotatedElement.getPropertyName(); if ( !idPropertiesIfIdClass.contains( propertyName ) ) { processElementAnnotations( propertyHolder, subclassAndSingleTableStrategy ? Nullability.FORCED_NULL : Nullability.NO_CONSTRAINT, propertyAnnotatedElement, classGenerators, entityBinder, false, false, false, mappings, inheritanceStatePerClass ); } else { missingIdProperties.remove( propertyName ); } } if ( missingIdProperties.size() != 0 ) { StringBuilder missings = new StringBuilder(); for ( String property : missingIdProperties ) { missings.append( property ).append( ", " ); } throw new AnnotationException( "Unable to find properties (" + missings.substring( 0, missings.length() - 2 ) + ") in entity annotated with @IdClass:" + persistentClass.getEntityName() ); } }
private static PersistentClass getSuperEntity(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, Mappings mappings, InheritanceState inheritanceState) { InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity( clazzToProcess, inheritanceStatePerClass ); PersistentClass superEntity = superEntityState != null ? mappings.getClass( superEntityState.getClazz().getName() ) : null; if ( superEntity == null ) { //check if superclass is not a potential persistent class if ( inheritanceState.hasParents() ) { throw new AssertionFailure( "Subclass has to be binded after it's mother class: " + superEntityState.getClazz().getName() ); } } return superEntity; }
public void linkValueUsingDefaultColumnNaming( Column referencedColumn, PersistentClass referencedEntity, SimpleValue value) { String columnName; String logicalReferencedColumn = getMappings().getLogicalColumnName( referencedColumn.getQuotedName(), referencedEntity.getTable() ); columnName = buildDefaultColumnName( referencedEntity, logicalReferencedColumn ); //yuk side effect on an implicit column setLogicalColumnName( columnName ); setReferencedColumn( logicalReferencedColumn ); initMappingColumn( columnName, null, referencedColumn.getLength(), referencedColumn.getPrecision(), referencedColumn.getScale(), getMappingColumn() != null ? getMappingColumn().isNullable() : false, referencedColumn.getSqlType(), getMappingColumn() != null ? getMappingColumn().isUnique() : false, false ); linkWithValue( value ); }
public static void linkJoinColumnWithValueOverridingNameIfImplicit( PersistentClass referencedEntity, Iterator columnIterator, Ejb3JoinColumn[] columns, SimpleValue value) { for (Ejb3JoinColumn joinCol : columns) { Column synthCol = (Column) columnIterator.next(); if ( joinCol.isNameDeferred() ) { //this has to be the default value joinCol.linkValueUsingDefaultColumnNaming( synthCol, referencedEntity, value ); } else { joinCol.linkWithValue( value ); joinCol.overrideFromReferencedColumnIfNecessary( synthCol ); } } }
private Set<String> processPersistentClassHierarchy( PersistentClass persistentClass, boolean isBase, SessionFactoryImplementor factory, String[][] mapping) { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // collect all the class names that indicate that the "main table" of the given PersistentClass should be // included when one of the collected class names is used in TREAT final Set<String> classNames = new HashSet<String>(); final Iterator itr = persistentClass.getDirectSubclasses(); while ( itr.hasNext() ) { final Subclass subclass = (Subclass) itr.next(); final Set<String> subclassSubclassNames = processPersistentClassHierarchy( subclass, false, factory, mapping ); classNames.addAll( subclassSubclassNames ); } classNames.add( persistentClass.getEntityName() ); if ( ! isBase ) { MappedSuperclass msc = persistentClass.getSuperMappedSuperclass(); while ( msc != null ) { classNames.add( msc.getMappedClass().getName() ); msc = msc.getSuperMappedSuperclass(); } associateSubclassNamesToSubclassTableIndexes( persistentClass, classNames, mapping, factory ); } return classNames; }
private void associateSubclassNamesToSubclassTableIndexes( PersistentClass persistentClass, Set<String> classNames, String[][] mapping, SessionFactoryImplementor factory) { final String tableName = persistentClass.getTable().getQualifiedName( factory.getDialect(), factory.getSettings().getDefaultCatalogName(), factory.getSettings().getDefaultSchemaName() ); associateSubclassNamesToSubclassTableIndex( tableName, classNames, mapping ); Iterator itr = persistentClass.getJoinIterator(); while ( itr.hasNext() ) { final Join join = (Join) itr.next(); final String secondaryTableName = join.getTable().getQualifiedName( factory.getDialect(), factory.getSettings().getDefaultCatalogName(), factory.getSettings().getDefaultSchemaName() ); associateSubclassNamesToSubclassTableIndex( secondaryTableName, classNames, mapping ); } }
@Override protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) { ProxyFactory pf = new MapProxyFactory(); try { //TODO: design new lifecycle for ProxyFactory pf.postInstantiate( getEntityName(), null, null, null, null, null ); } catch ( HibernateException he ) { LOG.unableToCreateProxyFactory( getEntityName(), he ); pf = null; } return pf; }
public static void bindClass(Element node, PersistentClass persistentClass, Mappings mappings, java.util.Map inheritedMetas) throws MappingException { // transfer an explicitly defined entity name // handle the lazy attribute Attribute lazyNode = node.attribute( "lazy" ); boolean lazy = lazyNode == null ? mappings.isDefaultLazy() : "true".equals( lazyNode.getValue() ); // go ahead and set the lazy here, since pojo.proxy can override it. persistentClass.setLazy( lazy ); String entityName = node.attributeValue( "entity-name" ); if ( entityName == null ) entityName = getClassName( node.attribute("name"), mappings ); if ( entityName==null ) { throw new MappingException( "Unable to determine entity name" ); } persistentClass.setEntityName( entityName ); persistentClass.setJpaEntityName( StringHelper.unqualify( entityName ) ); bindPojoRepresentation( node, persistentClass, mappings, inheritedMetas ); bindDom4jRepresentation( node, persistentClass, mappings, inheritedMetas ); bindMapRepresentation( node, persistentClass, mappings, inheritedMetas ); Iterator itr = node.elementIterator( "fetch-profile" ); while ( itr.hasNext() ) { final Element profileElement = ( Element ) itr.next(); parseFetchProfile( profileElement, mappings, entityName ); } bindPersistentClassCommonValues( node, persistentClass, mappings, inheritedMetas ); }
private static void bindDom4jRepresentation(Element node, PersistentClass entity, Mappings mappings, java.util.Map inheritedMetas) { String nodeName = node.attributeValue( "node" ); if (nodeName==null) nodeName = StringHelper.unqualify( entity.getEntityName() ); entity.setNodeName(nodeName); // Element tuplizer = locateTuplizerDefinition( node, EntityMode.DOM4J ); // if ( tuplizer != null ) { // entity.addTuplizer( EntityMode.DOM4J, tuplizer.attributeValue( "class" ) ); // } }
private static void bindMapRepresentation(Element node, PersistentClass entity, Mappings mappings, java.util.Map inheritedMetas) { Element tuplizer = locateTuplizerDefinition( node, EntityMode.MAP ); if ( tuplizer != null ) { entity.addTuplizer( EntityMode.MAP, tuplizer.attributeValue( "class" ) ); } }
private static void handleUnionSubclass(PersistentClass model, Mappings mappings, Element subnode, java.util.Map inheritedMetas) throws MappingException { UnionSubclass subclass = new UnionSubclass( model ); bindUnionSubclass( subnode, subclass, mappings, inheritedMetas ); model.addSubclass( subclass ); mappings.addClass( subclass ); }
private static void handleJoinedSubclass(PersistentClass model, Mappings mappings, Element subnode, java.util.Map inheritedMetas) throws MappingException { JoinedSubclass subclass = new JoinedSubclass( model ); bindJoinedSubclass( subnode, subclass, mappings, inheritedMetas ); model.addSubclass( subclass ); mappings.addClass( subclass ); }
private static void handleSubclass(PersistentClass model, Mappings mappings, Element subnode, java.util.Map inheritedMetas) throws MappingException { Subclass subclass = new SingleTableSubclass( model ); bindSubclass( subnode, subclass, mappings, inheritedMetas ); model.addSubclass( subclass ); mappings.addClass( subclass ); }
/** * Called for Lists, arrays, primitive arrays */ public static void bindListSecondPass(Element node, List list, java.util.Map classes, Mappings mappings, java.util.Map inheritedMetas) throws MappingException { bindCollectionSecondPass( node, list, classes, mappings, inheritedMetas ); Element subnode = node.element( "list-index" ); if ( subnode == null ) subnode = node.element( "index" ); SimpleValue iv = new SimpleValue( mappings, list.getCollectionTable() ); bindSimpleValue( subnode, iv, list.isOneToMany(), IndexedCollection.DEFAULT_INDEX_COLUMN_NAME, mappings ); iv.setTypeName( "integer" ); list.setIndex( iv ); String baseIndex = subnode.attributeValue( "base" ); if ( baseIndex != null ) list.setBaseIndex( Integer.parseInt( baseIndex ) ); list.setIndexNodeName( subnode.attributeValue("node") ); if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInverse() ) { String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName(); PersistentClass referenced = mappings.getClass( entityName ); IndexBackref ib = new IndexBackref(); ib.setName( '_' + list.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" ); ib.setUpdateable( false ); ib.setSelectable( false ); ib.setCollectionRole( list.getRole() ); ib.setEntityName( list.getOwner().getEntityName() ); ib.setValue( list.getIndex() ); // ( (Column) ( (SimpleValue) ic.getIndex() ).getColumnIterator().next() // ).setNullable(false); referenced.addProperty( ib ); } }
private static PersistentClass getSuperclass(Mappings mappings, Element subnode) throws MappingException { String extendsName = subnode.attributeValue( "extends" ); PersistentClass superModel = mappings.getClass( extendsName ); if ( superModel == null ) { String qualifiedExtendsName = getClassName( extendsName, mappings ); superModel = mappings.getClass( qualifiedExtendsName ); } if ( superModel == null ) { throw new MappingException( "Cannot extend unmapped class " + extendsName ); } return superModel; }
private void validate() throws MappingException { Iterator iter = classes.values().iterator(); while ( iter.hasNext() ) { ( (PersistentClass) iter.next() ).validate( mapping ); } iter = collections.values().iterator(); while ( iter.hasNext() ) { ( (Collection) iter.next() ).validate( mapping ); } }
protected void secondPassCompileForeignKeys(Table table, Set<ForeignKey> done) throws MappingException { table.createForeignKeys(); Iterator iter = table.getForeignKeyIterator(); while ( iter.hasNext() ) { ForeignKey fk = (ForeignKey) iter.next(); if ( !done.contains( fk ) ) { done.add( fk ); final String referencedEntityName = fk.getReferencedEntityName(); if ( referencedEntityName == null ) { throw new MappingException( "An association from the table " + fk.getTable().getName() + " does not specify the referenced entity" ); } LOG.debugf( "Resolving reference to class: %s", referencedEntityName ); PersistentClass referencedClass = classes.get( referencedEntityName ); if ( referencedClass == null ) { throw new MappingException( "An association from the table " + fk.getTable().getName() + " refers to an unmapped class: " + referencedEntityName ); } if ( referencedClass.isJoinedSubclass() ) { secondPassCompileForeignKeys( referencedClass.getSuperclass().getTable(), done ); } fk.setReferencedTable( referencedClass.getTable() ); fk.alignColumns(); } } }
public PojoInstantiator(PersistentClass persistentClass, ReflectionOptimizer.InstantiationOptimizer optimizer) { this.mappedClass = persistentClass.getMappedClass(); this.isAbstract = ReflectHelper.isAbstractClass( mappedClass ); this.proxyInterface = persistentClass.getProxyInterface(); this.embeddedIdentifier = persistentClass.hasEmbeddedIdentifier(); this.optimizer = optimizer; try { constructor = ReflectHelper.getDefaultConstructor( mappedClass ); } catch ( PropertyNotFoundException pnfe ) { LOG.noDefaultConstructor(mappedClass.getName()); constructor = null; } }
public ClassPropertyHolder( PersistentClass persistentClass, XClass entityXClass, Map<String, Join> joins, Mappings mappings, Map<XClass, InheritanceState> inheritanceStatePerClass) { super( persistentClass.getEntityName(), null, entityXClass, mappings ); this.persistentClass = persistentClass; this.joins = joins; this.inheritanceStatePerClass = inheritanceStatePerClass; this.attributeConversionInfoMap = buildAttributeConversionInfoMap( entityXClass ); }
public ClassPropertyHolder( PersistentClass persistentClass, XClass entityXClass, EntityBinder entityBinder, Mappings mappings, Map<XClass, InheritanceState> inheritanceStatePerClass) { this( persistentClass, entityXClass, entityBinder.getSecondaryTables(), mappings, inheritanceStatePerClass ); this.entityBinder = entityBinder; }
@Override public boolean isInPrimaryKey() { if ( entityClassName == null ) return false; final PersistentClass persistentClass = mappings.getClass( entityClassName ); Property property = persistentClass.getIdentifierProperty(); if ( path == null ) { return false; } else if ( property != null) { //try explicit identifier property return path.startsWith( property.getName() + "." ); } else { //try the embedded property //embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationSourceProcessor if ( path.startsWith( "id." ) ) { KeyValue valueIdentifier = persistentClass.getIdentifier(); String localPath = path.substring( 3 ); if ( valueIdentifier instanceof Component ) { Iterator it = ( (Component) valueIdentifier ).getPropertyIterator(); while ( it.hasNext() ) { Property idProperty = (Property) it.next(); if ( localPath.startsWith( idProperty.getName() ) ) return true; } } } } return false; }
private static void applyDDL( String prefix, PersistentClass persistentClass, Class<?> clazz, ValidatorFactory factory, Set<Class<?>> groups, boolean activateNotNull, Dialect dialect) { final BeanDescriptor descriptor = factory.getValidator().getConstraintsForClass( clazz ); //no bean level constraints can be applied, go to the properties for ( PropertyDescriptor propertyDesc : descriptor.getConstrainedProperties() ) { Property property = findPropertyByName( persistentClass, prefix + propertyDesc.getPropertyName() ); boolean hasNotNull; if ( property != null ) { hasNotNull = applyConstraints( propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect ); if ( property.isComposite() && propertyDesc.isCascaded() ) { Class<?> componentClass = ( (Component) property.getValue() ).getComponentClass(); /* * we can apply not null if the upper component let's us activate not null * and if the property is not null. * Otherwise, all sub columns should be left nullable */ final boolean canSetNotNullOnColumns = activateNotNull && hasNotNull; applyDDL( prefix + propertyDesc.getPropertyName() + ".", persistentClass, componentClass, factory, groups, canSetNotNullOnColumns, dialect ); } //FIXME add collection of components } } }
/** * Builds the <code>Join</code> instance for the mapped by side of a <i>OneToOne</i> association using * a join tables. * <p> * Note:<br/> * <ul> * <li>From the mappedBy side we should not create the PK nor the FK, this is handled from the other side.</li> * <li>This method is a dirty dupe of EntityBinder.bindSecondaryTable</i>. * </p> */ private Join buildJoinFromMappedBySide(PersistentClass persistentClass, Property otherSideProperty, Join originalJoin) { Join join = new Join(); join.setPersistentClass( persistentClass ); //no check constraints available on joins join.setTable( originalJoin.getTable() ); join.setInverse( true ); SimpleValue key = new DependantValue( mappings, join.getTable(), persistentClass.getIdentifier() ); //TODO support @ForeignKey join.setKey( key ); join.setSequentialSelect( false ); //TODO support for inverse and optional join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway key.setCascadeDeleteEnabled( false ); Iterator mappedByColumns = otherSideProperty.getValue().getColumnIterator(); while ( mappedByColumns.hasNext() ) { Column column = (Column) mappedByColumns.next(); Column copy = new Column(); copy.setLength( column.getLength() ); copy.setScale( column.getScale() ); copy.setValue( key ); copy.setName( column.getQuotedName() ); copy.setNullable( column.isNullable() ); copy.setPrecision( column.getPrecision() ); copy.setUnique( column.isUnique() ); copy.setSqlType( column.getSqlType() ); copy.setCheckConstraint( column.getCheckConstraint() ); copy.setComment( column.getComment() ); copy.setDefaultValue( column.getDefaultValue() ); key.addColumn( copy ); } persistentClass.addJoin( join ); return join; }
private void addMappedSuperClassInMetadata(PersistentClass persistentClass) { //add @MappedSuperclass in the metadata // classes from 0 to n-1 are @MappedSuperclass and should be linked org.hibernate.mapping.MappedSuperclass mappedSuperclass = null; final InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity( clazz, inheritanceStatePerClass ); PersistentClass superEntity = superEntityState != null ? mappings.getClass( superEntityState.getClazz().getName() ) : null; final int lastMappedSuperclass = classesToProcessForMappedSuperclass.size() - 1; for ( int index = 0; index < lastMappedSuperclass; index++ ) { org.hibernate.mapping.MappedSuperclass parentSuperclass = mappedSuperclass; final Class<?> type = mappings.getReflectionManager() .toClass( classesToProcessForMappedSuperclass.get( index ) ); //add MAppedSuperclass if not already there mappedSuperclass = mappings.getMappedSuperclass( type ); if ( mappedSuperclass == null ) { mappedSuperclass = new org.hibernate.mapping.MappedSuperclass( parentSuperclass, superEntity ); mappedSuperclass.setMappedClass( type ); mappings.addMappedSuperclass( type, mappedSuperclass ); } } if ( mappedSuperclass != null ) { persistentClass.setSuperMappedSuperclass( mappedSuperclass ); } }
public void doSecondPass(Map persistentClasses) throws MappingException { PersistentClass referencedEntity = (PersistentClass) persistentClasses.get( referencedEntityName ); if ( referencedEntity == null ) { throw new AnnotationException( "Unknown entity name: " + referencedEntityName ); }; TableBinder.linkJoinColumnWithValueOverridingNameIfImplicit( referencedEntity, referencedEntity.getKey().getColumnIterator(), columns, value); }
/** * Override persistent class on oneToMany Cases for late settings * Must only be used on second level pass binding */ public void setPersistentClass( PersistentClass persistentClass, Map<String, Join> joins, Map<XClass, InheritanceState> inheritanceStatePerClass) { // TODO shouldn't we deduce the classname from the persistentclasS? this.propertyHolder = PropertyHolderBuilder.buildPropertyHolder( persistentClass, joins, getMappings(), inheritanceStatePerClass ); }
public void copyReferencedStructureAndCreateDefaultJoinColumns( PersistentClass referencedEntity, Iterator columnIterator, SimpleValue value) { if ( !isNameDeferred() ) { throw new AssertionFailure( "Building implicit column but the column is not implicit" ); } while ( columnIterator.hasNext() ) { Column synthCol = (Column) columnIterator.next(); this.linkValueUsingDefaultColumnNaming( synthCol, referencedEntity, value ); } //reset for the future setMappingColumn( null ); }
public static PropertyHolder buildPropertyHolder( XClass clazzToProcess, PersistentClass persistentClass, EntityBinder entityBinder, Mappings mappings, Map<XClass, InheritanceState> inheritanceStatePerClass) { return new ClassPropertyHolder( persistentClass, clazzToProcess, entityBinder, mappings, inheritanceStatePerClass ); }
/** * must only be used on second level phases (<join> has to be settled already) */ public static PropertyHolder buildPropertyHolder( PersistentClass persistentClass, Map<String, Join> joins, Mappings mappings, Map<XClass, InheritanceState> inheritanceStatePerClass) { return new ClassPropertyHolder( persistentClass, null, joins, mappings, inheritanceStatePerClass ); }
private static String buildOrderByClauseFromHql(String orderByFragment, PersistentClass associatedClass, String role) { if ( orderByFragment != null ) { if ( orderByFragment.length() == 0 ) { //order by id return "id asc"; } else if ( "desc".equals( orderByFragment ) ) { return "id desc"; } } return orderByFragment; }
private static Constructor getConstructor(PersistentClass persistentClass) { if ( persistentClass == null || !persistentClass.hasPojoRepresentation() ) { return null; } try { return ReflectHelper.getDefaultConstructor( persistentClass.getMappedClass() ); } catch( Throwable t ) { return null; } }
public EntityBinder( Entity ejb3Ann, org.hibernate.annotations.Entity hibAnn, XClass annotatedClass, PersistentClass persistentClass, Mappings mappings) { this.mappings = mappings; this.persistentClass = persistentClass; this.annotatedClass = annotatedClass; bindEjb3Annotation( ejb3Ann ); bindHibernateAnnotation( hibAnn ); }
/** * Essentially we are building a mapping that we can later use to determine whether a given "subclass table" * should be included in joins when JPA TREAT-AS is used. * * @param persistentClass * @param factory * @return */ private String[][] buildSubclassNamesBySubclassTableMapping(PersistentClass persistentClass, SessionFactoryImplementor factory) { // this value represents the number of subclasses (and not the class itself) final int numberOfSubclassTables = subclassTableNameClosure.length - coreTableSpan; if ( numberOfSubclassTables == 0 ) { return new String[0][]; } final String[][] mapping = new String[numberOfSubclassTables][]; processPersistentClassHierarchy( persistentClass, true, factory, mapping ); return mapping; }
public Dom4jInstantiator(PersistentClass mappingInfo) { this.nodeName = mappingInfo.getNodeName(); isInstanceNodeNames.add( nodeName ); if ( mappingInfo.hasSubclasses() ) { Iterator itr = mappingInfo.getSubclassClosureIterator(); while ( itr.hasNext() ) { final PersistentClass subclassInfo = ( PersistentClass ) itr.next(); isInstanceNodeNames.add( subclassInfo.getNodeName() ); } } }