public String getClassName() { return persistentClass.getClassName(); }
public boolean hasPojoRepresentation() { return getClassName() != null; }
private String extractUserPropertyName(String redundantString, String propertyName) { String result = null; String className = component.getOwner().getClassName(); if ( propertyName.startsWith( className ) && propertyName.length() > className.length() + 2 + redundantString.length() // .id. && propertyName.substring( className.length() + 1, className.length() + 1 + redundantString.length() ).equals( redundantString ) ) { //remove id we might be in a @IdCLass case result = className + propertyName.substring( className.length() + 1 + redundantString.length() ); } return result; }
public String getEntityOwnerClassName() { return component.getOwner().getClassName(); }
public EntityNamingSourceImpl(PersistentClass entityBinding) { this( entityBinding.getEntityName(), entityBinding.getClassName(), entityBinding.getJpaEntityName() ); }
@Override public void addEntityBinding(PersistentClass persistentClass) throws DuplicateMappingException { final String entityName = persistentClass.getEntityName(); final String jpaEntityName = persistentClass.getJpaEntityName(); if ( entityBindingMap.containsKey( entityName ) ) { throw new DuplicateMappingException( DuplicateMappingException.Type.ENTITY, entityName ); } PersistentClass matchingPersistentClass = entityBindingMap.values() .stream() .filter( existingPersistentClass -> existingPersistentClass.getJpaEntityName().equals( jpaEntityName ) ) .findFirst() .orElse( null ); if ( matchingPersistentClass != null ) { throw new DuplicateMappingException( String.format( "The [%s] and [%s] entities share the same JPA entity name: [%s] which is not allowed!", matchingPersistentClass.getClassName(), persistentClass.getClassName(), jpaEntityName ), DuplicateMappingException.Type.ENTITY, jpaEntityName ); } entityBindingMap.put( entityName, persistentClass ); }
@Override protected Instantiator buildInstantiator( EntityMetamodel entityMetamodel, PersistentClass persistentClass) { return new DynamicInstantiator( persistentClass.getClassName() ); }
@Override public void prepare(MetadataImplementor metadata) { if ( callbackBuilder == null ) { // TODO : not needed anymore when the deprecate constructor will be removed this.callbackBuilder = CallbacksFactory.buildCallbackBuilder( sessionFactory, metadata.getMetadataBuildingOptions().getReflectionManager() ); } for ( PersistentClass persistentClass : metadata.getEntityBindings() ) { if ( persistentClass.getClassName() == null ) { // we can have non java class persisted by hibernate continue; } callbackBuilder.buildCallbacksForEntity( persistentClass.getClassName(), callbackRegistry ); for ( Iterator propertyIterator = persistentClass.getDeclaredPropertyIterator(); propertyIterator.hasNext(); ) { Property property = (Property) propertyIterator.next(); if ( property.getType().isComponentType() ) { callbackBuilder.buildCallbacksForEmbeddable( property, persistentClass.getClassName(), callbackRegistry ); } } } }
final String className = persistentClass.getClassName();
private String getMappedBy(PersistentClass referencedClass, ValueHolder valueHolder) { // If there's an @AuditMappedBy specified, returning it directly. final String auditMappedBy = propertyAuditingData.getAuditMappedBy(); if ( auditMappedBy != null ) { return auditMappedBy; } // searching in referenced class String mappedBy = this.searchMappedBy( referencedClass, valueHolder ); if ( mappedBy == null ) { LOG.debugf( "Going to search the mapped by attribute for %s in superclasses of entity: %s", propertyName, referencedClass.getClassName() ); PersistentClass tempClass = referencedClass; while ( mappedBy == null && tempClass.getSuperclass() != null ) { LOG.debugf( "Searching in superclass: %s", tempClass.getSuperclass().getClassName() ); mappedBy = this.searchMappedBy( tempClass.getSuperclass(), valueHolder ); tempClass = tempClass.getSuperclass(); } } if ( mappedBy == null ) { throw new MappingException( "Unable to read the mapped by attribute for " + propertyName + " in " + referencedClass.getClassName() + "!" ); } return mappedBy; }
public ClassAuditingData getAuditData() { if ( pc.getClassName() == null ) { return auditData; } try { final XClass xclass = reflectionManager.classForName( pc.getClassName() ); final ModificationStore defaultStore = getDefaultAudited( xclass ); if ( defaultStore != null ) { auditData.setDefaultAudited( true ); } new AuditedPropertiesReader( defaultStore, new PersistentClassPropertiesSource( xclass ), auditData, globalCfg, reflectionManager, "" ).read(); addAuditTable( xclass ); addAuditSecondaryTables( xclass ); } catch (ClassLoadingException e) { throw new MappingException( e ); } return auditData; }
@Test public void testRevisionInfoTableNotCreated() { @SuppressWarnings({"unchecked"}) List<PersistentClass> pcs = collectionToList( metadata().getEntityBindings() ); Assert.assertEquals( 1, pcs.size() ); Assert.assertTrue( pcs.get( 0 ).getClassName().contains( "BasicTestEntity3" ) ); } }
public static NativeSQLQueryReturn extractReturnDescription( JaxbHbmNativeQueryCollectionLoadReturnType rtnSource, HbmLocalMetadataBuildingContext context, int queryReturnPosition) { final int dot = rtnSource.getRole().lastIndexOf( '.' ); if ( dot == -1 ) { throw new MappingException( String.format( Locale.ENGLISH, "Collection attribute for sql query return [%s] not formatted correctly {OwnerClassName.propertyName}", rtnSource.getAlias() ), context.getOrigin() ); } String ownerClassName = context.findEntityBinding( null, rtnSource.getRole().substring( 0, dot ) ) .getClassName(); String ownerPropertyName = rtnSource.getRole().substring( dot + 1 ); return new NativeSQLQueryCollectionReturn( rtnSource.getAlias(), ownerClassName, ownerPropertyName, // FIXME: get the PersistentClass extractPropertyResults( rtnSource.getAlias(), rtnSource, null, context ), rtnSource.getLockMode() ); }
if (pc.getClassName() != null) {
public static Component createComponent( PropertyHolder propertyHolder, PropertyData inferredData, boolean isComponentEmbedded, boolean isIdentifierMapper, MetadataBuildingContext context) { Component comp = new Component( context, propertyHolder.getPersistentClass() ); comp.setEmbedded( isComponentEmbedded ); //yuk comp.setTable( propertyHolder.getTable() ); //FIXME shouldn't identifier mapper use getClassOrElementName? Need to be checked. if ( isIdentifierMapper || ( isComponentEmbedded && inferredData.getPropertyName() == null ) ) { comp.setComponentClassName( comp.getOwner().getClassName() ); } else { comp.setComponentClassName( inferredData.getClassOrElementName() ); } return comp; }
private static void bindCollectionSecondPass( Collection collValue, PersistentClass collectionEntity, Ejb3JoinColumn[] joinColumns, boolean cascadeDeleteEnabled, XProperty property, PropertyHolder propertyHolder, MetadataBuildingContext buildingContext) { try { BinderHelper.createSyntheticPropertyReference( joinColumns, collValue.getOwner(), collectionEntity, collValue, false, buildingContext ); } catch (AnnotationException ex) { throw new AnnotationException( "Unable to map collection " + collValue.getOwner().getClassName() + "." + property.getName(), ex ); } SimpleValue key = buildCollectionKey( collValue, joinColumns, cascadeDeleteEnabled, property, propertyHolder, buildingContext ); if ( property.isAnnotationPresent( ElementCollection.class ) && joinColumns.length > 0 ) { joinColumns[0].setJPA2ElementCollection( true ); } TableBinder.bindFk( collValue.getOwner(), collectionEntity, joinColumns, key, false, buildingContext ); }
private EntityMetamodel getDeclarerEntityMetamodel(AbstractIdentifiableType<?> ownerType) { final Type.PersistenceType persistenceType = ownerType.getPersistenceType(); if ( persistenceType == Type.PersistenceType.ENTITY ) { return context.getSessionFactory() .getMetamodel() .entityPersister( ownerType.getTypeName() ) .getEntityMetamodel(); } else if ( persistenceType == Type.PersistenceType.MAPPED_SUPERCLASS ) { PersistentClass persistentClass = context.getPersistentClassHostingProperties( (MappedSuperclassTypeImpl<?>) ownerType ); return context.getSessionFactory() .getMetamodel() .entityPersister( persistentClass.getClassName() ) .getEntityMetamodel(); } else { throw new AssertionFailure( "Cannot get the metamodel for PersistenceType: " + persistenceType ); } }
static PropertyData getPropertyOverriddenByMapperOrMapsId( boolean isId, PropertyHolder propertyHolder, String propertyName, MetadataBuildingContext buildingContext) { final XClass persistentXClass; try { persistentXClass = buildingContext.getBootstrapContext().getReflectionManager() .classForName( propertyHolder.getPersistentClass().getClassName() ); } catch ( ClassLoadingException e ) { throw new AssertionFailure( "PersistentClass name cannot be converted into a Class", e); } if ( propertyHolder.isInIdClass() ) { PropertyData pd = buildingContext.getMetadataCollector().getPropertyAnnotatedWithIdAndToOne( persistentXClass, propertyName ); if ( pd == null && buildingContext.getBuildingOptions().isSpecjProprietarySyntaxEnabled() ) { pd = buildingContext.getMetadataCollector().getPropertyAnnotatedWithMapsId( persistentXClass, propertyName ); } return pd; } String propertyPath = isId ? "" : propertyName; return buildingContext.getMetadataCollector().getPropertyAnnotatedWithMapsId( persistentXClass, propertyPath ); }
InFlightMetadataCollector.EntityTableXref denormalizedSuperTableXref) { EntityTableNamingStrategyHelper namingStrategyHelper = new EntityTableNamingStrategyHelper( persistentClass.getClassName(), persistentClass.getEntityName(), name
final EntityNaming ownerEntityNaming = new EntityNamingSourceImpl( collectionBinding.getOwner().getEntityName(), collectionBinding.getOwner().getClassName(), collectionBinding.getOwner().getJpaEntityName() );