private Property bind(Property prop) { if (isId) { final RootClass rootClass = ( RootClass ) holder.getPersistentClass(); holder.addProperty( prop, columns, declaringClass );
String entityName = ( propertyHolder.isComponent() ) ? propertyHolder.getPersistentClass().getEntityName() : propertyHolder.getEntityName();
public Join getJoin() { Join join = joins.get( explicitTableName ); if ( join == null ) { // annotation binding seems to use logical and physical naming somewhat inconsistently... final String physicalTableName = getBuildingContext().getMetadataCollector().getPhysicalTableName( explicitTableName ); if ( physicalTableName != null ) { join = joins.get( physicalTableName ); } } if ( join == null ) { throw new AnnotationException( "Cannot find the expected secondary table: no " + explicitTableName + " available for " + propertyHolder.getClassName() ); } return join; }
@Override public boolean isCollectionElement() { // if the propertyHolder is a collection, assume the // @Column refers to the element column return !propertyHolder.isComponent() && !propertyHolder.isEntity(); }
public static String getRelativePath(PropertyHolder propertyHolder, String propertyName) { if ( propertyHolder == null ) { return propertyName; } String path = propertyHolder.getPath(); String entityName = propertyHolder.getPersistentClass().getEntityName(); if ( path.length() == entityName.length() ) { return propertyName; } else { return StringHelper.qualify( path.substring( entityName.length() + 1 ), propertyName ); } }
String suffixForDefaultColumnName, MetadataBuildingContext buildingContext) { JoinColumn[] actualColumns = propertyHolder.getOverriddenJoinColumn( StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); if ( actualColumns == null ) actualColumns = anns;
if ( !propertyHolder.isComponent() ) { if ( entityBinder.isPropertyDefinedInSuperHierarchy( inferredData.getPropertyName() ) ) { LOG.debugf( LOG.tracev( "Processing annotations of {0}.{1}" , propertyHolder.getEntityName(), inferredData.getPropertyName() ); if ( propertyHolder.isComponent() ) { propertyHolder.setParentProperty( property.getName() ); if ( !( propertyHolder.getPersistentClass() instanceof RootClass ) ) { throw new AnnotationException( "Unable to define/override @Version on a subclass: " + propertyHolder.getEntityName() ); if ( !propertyHolder.isEntity() ) { throw new AnnotationException( "Unable to define @Version on an embedded class: " + propertyHolder.getEntityName() ); RootClass rootClass = ( RootClass ) propertyHolder.getPersistentClass(); propertyBinder.setColumns( columns ); Property prop = propertyBinder.makePropertyValueAndBind(); NotFound notFound = property.getAnnotation( NotFound.class ); boolean ignoreNotFound = notFound != null && notFound.action().equals( NotFoundAction.IGNORE ); matchIgnoreNotFoundWithFetchType(propertyHolder.getEntityName(), property.getName(), ignoreNotFound, ann.fetch()); OnDelete onDeleteAnn = property.getAnnotation( OnDelete.class );
public void doSecondPass(Map persistentClasses) throws MappingException { org.hibernate.mapping.OneToOne value = new org.hibernate.mapping.OneToOne( buildingContext, propertyHolder.getTable(), propertyHolder.getPersistentClass() ); final String propertyName = inferredData.getPropertyName(); String path = StringHelper.qualify( propertyHolder.getPath(), propertyName ); final ToOneFkSecondPass secondPass = new ToOneFkSecondPass( value, joinColumns, propertyHolder.getEntityOwnerClassName(), path, buildingContext secondPass.doSecondPass( persistentClasses ); propertyHolder.addProperty( prop, inferredData.getDeclaringClass() ); propertyHolder.addProperty( prop, inferredData.getDeclaringClass() ); propertyHolder.addProperty( prop, inferredData.getDeclaringClass() );
value.setTypeUsingReflection( propertyHolder.getClassName(), propertyName ); propertyHolder.getOverriddenForeignKey( StringHelper.qualify( propertyHolder.getPath(), propertyName ) ), joinColumn, joinColumns ); String path = propertyHolder.getPath() + "." + propertyName; FkSecondPass secondPass = new ToOneFkSecondPass( value, columns, propertyHolder.getEntityOwnerClassName(), path, context context.getMetadataCollector().addSecondPass( secondPass ); Ejb3Column.checkPropertyConsistency( columns, propertyHolder.getEntityName() + "." + propertyName );
public void bind() { this.collection = createCollection( propertyHolder.getPersistentClass() ); String role = StringHelper.qualify( propertyHolder.getPath(), propertyName ); LOG.debugf( "Collection role: %s", role ); collection.setRole( role ); "Cannot mix @javax.persistence.MapKey and @MapKeyColumn or @org.hibernate.annotations.MapKey " + "on the same collection: " + StringHelper.qualify( propertyHolder.getPath(), propertyName && (property.isAnnotationPresent( JoinColumn.class ) || property.isAnnotationPresent( JoinColumns.class ) || propertyHolder.getJoinTable( property ) != null ) ) { String message = "Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn: "; message += StringHelper.qualify( propertyHolder.getPath(), propertyName ); throw new AnnotationException( message ); && !property.isAnnotationPresent( JoinColumn.class )) { String message = "Unidirectional one-to-many associations annotated with @OnDelete must define @JoinColumn: "; message += StringHelper.qualify( propertyHolder.getPath(), propertyName ); throw new AnnotationException( message ); propertyHolder.addProperty( prop, declaringClass );
if ( !trueOneToOne ) { KeyValue identifier = propertyHolder.getIdentifier(); if ( identifier == null ) { propertyHolder.getEntityName(), propertyName, propertyHolder,
javax.persistence.Column[] overriddenCols = propertyHolder.getOverriddenColumn( StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() ) ); if ( overriddenCols != null ) {
columns[0].getPropertyHolder().getPersistentClass() : null; if ( Ejb3JoinColumn.NON_PK_REFERENCE == fkEnum ) { if ( columns[0].getPropertyHolder() != null ) { columnsList.append( "of " ) .append( columns[0].getPropertyHolder().getEntityName() ) .append( "." ) .append( columns[0].getPropertyName() )
if ( propertyHolder.isComponent() ) { propertyHolder.setParentProperty( property.getName() ); ); if ( ! ( propertyHolder.getPersistentClass() instanceof RootClass ) ) { throw new AnnotationException( "Unable to define/override @Version on a subclass: " throw new AnnotationException( "@OneToMany and @ManyToMany on the same property is not allowed: " + propertyHolder.getEntityName() + "." + inferredData.getPropertyName() );
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; }
public static String getPath(PropertyHolder holder, PropertyData property) { return StringHelper.qualify( holder.getPath(), property.getPropertyName() ); }
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 ); }
LOG.debugf( "Binding a OneToMany: %s.%s through a foreign key", propertyHolder.getEntityName(), propertyName ); throw new MappingException( String.format("Association [%s] for entity [%s] references unmapped class [%s]", propertyName, propertyHolder.getClassName(), assocClass) );
+ StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() ) ); Ejb3Column.checkPropertyConsistency( columns, propertyHolder.getEntityName() + "." + propertyName ); for (Ejb3JoinColumn column : columns) { column.linkWithValue( value );
String entityName = joinColumns[0].getManyToManyOwnerSideEntityName() != null ? "inverse__" + joinColumns[0].getManyToManyOwnerSideEntityName() : joinColumns[0].getPropertyHolder().getEntityName(); String propRef = buildingContext.getMetadataCollector().getPropertyReferencedAssociation( entityName, final javax.persistence.ForeignKey fkOverride = propertyHolder.getOverriddenForeignKey( StringHelper.qualify( propertyHolder.getPath(), property.getName() ) ); if ( fkOverride != null && fkOverride.value() == ConstraintMode.NO_CONSTRAINT ) {