this.currentPropertyColumnOverride = buildColumnOverride( property, getPath() ); if ( this.currentPropertyColumnOverride.size() == 0 ) { this.currentPropertyColumnOverride = null; this.currentPropertyJoinColumnOverride = buildJoinColumnOverride( property, getPath() ); if ( this.currentPropertyJoinColumnOverride.size() == 0 ) { this.currentPropertyJoinColumnOverride = null; this.currentPropertyJoinTableOverride = buildJoinTableOverride( property, getPath() ); if ( this.currentPropertyJoinTableOverride.size() == 0 ) { this.currentPropertyJoinTableOverride = null; this.currentPropertyForeignKeyOverride = buildForeignKeyOverride( property, getPath() ); if ( this.currentPropertyForeignKeyOverride.size() == 0 ) { this.currentPropertyForeignKeyOverride = null;
AbstractPropertyHolder( String path, PropertyHolder parent, XClass clazzToProcess, MetadataBuildingContext context) { this.path = path; this.parent = (AbstractPropertyHolder) parent; this.context = context; buildHierarchyColumnOverride( clazzToProcess ); }
@Override public Column[] getOverriddenColumn(String propertyName) { //FIXME this is yukky Column[] result = super.getOverriddenColumn( propertyName ); if ( result == null ) { String userPropertyName = extractUserPropertyName( "id", propertyName ); if ( userPropertyName != null ) result = super.getOverriddenColumn( userPropertyName ); } if ( result == null ) { String userPropertyName = extractUserPropertyName( PropertyPath.IDENTIFIER_MAPPER_PROPERTY, propertyName ); if ( userPropertyName != null ) result = super.getOverriddenColumn( userPropertyName ); } return result; }
/** * Get column overriding, property first, then parent, then holder * replace the placeholder 'collection&&element' with nothing * * These rules are here to support both JPA 2 and legacy overriding rules. */ @Override public JoinTable getJoinTable(XProperty property) { final String propertyName = StringHelper.qualify( getPath(), property.getName() ); JoinTable result = getOverriddenJoinTable( propertyName ); if (result == null) { result = property.getAnnotation( JoinTable.class ); } return result; }
/** * property can be null */ protected void setCurrentProperty(XProperty property) { if ( property == null ) { this.currentPropertyColumnOverride = null; this.currentPropertyJoinColumnOverride = null; } else { this.currentPropertyColumnOverride = buildColumnOverride( property, getPath() ); if ( this.currentPropertyColumnOverride.size() == 0 ) { this.currentPropertyColumnOverride = null; } this.currentPropertyJoinColumnOverride = buildJoinColumnOverride( property, getPath() ); if ( this.currentPropertyJoinColumnOverride.size() == 0 ) { this.currentPropertyJoinColumnOverride = null; } } }
/** * Get column overriding, property first, then parent, then holder * replace the placeholder 'collection&&element' with nothing * * These rules are here to support both JPA 2 and legacy overriding rules. */ @Override public JoinColumn[] getOverriddenJoinColumn(String propertyName) { JoinColumn[] result = getExactOverriddenJoinColumn( propertyName ); if ( result == null && propertyName.contains( ".collection&&element." ) ) { //support for non map collections where no prefix is needed //TODO cache the underlying regexp result = getExactOverriddenJoinColumn( propertyName.replace( ".collection&&element.", "." ) ); } return result; }
/** * Get column overriding, property first, then parent, then holder * find the overridden rules from the exact property name. */ private Column[] getExactOverriddenColumn(String propertyName) { Column[] override = null; if ( parent != null ) { override = parent.getExactOverriddenColumn( propertyName ); } if ( override == null && currentPropertyColumnOverride != null ) { override = currentPropertyColumnOverride.get( propertyName ); } if ( override == null && holderColumnOverride != null ) { override = holderColumnOverride.get( propertyName ); } return override; }
@Override public JoinColumn[] getOverriddenJoinColumn(String propertyName) { return super.getOverriddenJoinColumn( propertyName ); }
public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation) { return parent.addJoin( joinTableAnn, noDelayInPkColumnCreation ); }
private void buildHierarchyColumnOverride(XClass element) { XClass current = element; Map<String, Column[]> columnOverride = new HashMap<String, Column[]>(); Map<String, JoinColumn[]> joinColumnOverride = new HashMap<String, JoinColumn[]>(); while ( current != null && ! mappings.getReflectionManager().toXClass( Object.class ).equals( current ) ) { if ( current.isAnnotationPresent( Entity.class ) || current.isAnnotationPresent( MappedSuperclass.class ) || current.isAnnotationPresent( Embeddable.class ) ) { //FIXME is embeddable override? Map<String, Column[]> currentOverride = buildColumnOverride( current, getPath() ); Map<String, JoinColumn[]> currentJoinOverride = buildJoinColumnOverride( current, getPath() ); currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses columnOverride = currentOverride; joinColumnOverride = currentJoinOverride; } current = current.getSuperclass(); } holderColumnOverride = columnOverride.size() > 0 ? columnOverride : null; holderJoinColumnOverride = joinColumnOverride.size() > 0 ? joinColumnOverride : null; }
/** * Get column overriding, property first, then parent, then holder * replace the placeholder 'collection&&element' with nothing * * These rules are here to support both JPA 2 and legacy overriding rules. * */ public JoinTable getJoinTable(XProperty property) { final String propertyName = StringHelper.qualify( getPath(), property.getName() ); JoinTable result = getOverriddenJoinTable( propertyName ); if (result == null) { result = property.getAnnotation( JoinTable.class ); } return result; }
/** * Get column overriding, property first, then parent, then holder */ private JoinColumn[] getExactOverriddenJoinColumn(String propertyName) { JoinColumn[] override = null; if ( parent != null ) { override = parent.getExactOverriddenJoinColumn( propertyName ); } if ( override == null && currentPropertyJoinColumnOverride != null ) { override = currentPropertyJoinColumnOverride.get( propertyName ); } if ( override == null && holderJoinColumnOverride != null ) { override = holderJoinColumnOverride.get( propertyName ); } return override; }
Column[] result = getExactOverriddenColumn( propertyName ); if (result == null) { result = getExactOverriddenColumn( propertyName.replace( ".collection&&element.", "." ) );
@Override public JoinColumn[] getOverriddenJoinColumn(String propertyName) { return super.getOverriddenJoinColumn( propertyName ); } }
public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation) { return parent.addJoin( joinTableAnn, noDelayInPkColumnCreation ); }
private void buildHierarchyColumnOverride(XClass element) { XClass current = element; Map<String, Column[]> columnOverride = new HashMap<String, Column[]>(); Map<String, JoinColumn[]> joinColumnOverride = new HashMap<String, JoinColumn[]>(); Map<String, JoinTable> joinTableOverride = new HashMap<String, JoinTable>(); Map<String, ForeignKey> foreignKeyOverride = new HashMap<String, ForeignKey>(); while ( current != null && !context.getBootstrapContext().getReflectionManager().toXClass( Object.class ).equals( current ) ) { if ( current.isAnnotationPresent( Entity.class ) || current.isAnnotationPresent( MappedSuperclass.class ) || current.isAnnotationPresent( Embeddable.class ) ) { //FIXME is embeddable override? Map<String, Column[]> currentOverride = buildColumnOverride( current, getPath() ); Map<String, JoinColumn[]> currentJoinOverride = buildJoinColumnOverride( current, getPath() ); Map<String, JoinTable> currentJoinTableOverride = buildJoinTableOverride( current, getPath() ); Map<String, ForeignKey> currentForeignKeyOverride = buildForeignKeyOverride( current, getPath() ); currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses currentJoinTableOverride.putAll( joinTableOverride ); //subclasses have precedence over superclasses currentForeignKeyOverride.putAll( foreignKeyOverride ); //subclasses have precedence over superclasses columnOverride = currentOverride; joinColumnOverride = currentJoinOverride; joinTableOverride = currentJoinTableOverride; foreignKeyOverride = currentForeignKeyOverride; } current = current.getSuperclass(); } holderColumnOverride = columnOverride.size() > 0 ? columnOverride : null; holderJoinColumnOverride = joinColumnOverride.size() > 0 ? joinColumnOverride : null; holderJoinTableOverride = joinTableOverride.size() > 0 ? joinTableOverride : null; holderForeignKeyOverride = foreignKeyOverride.size() > 0 ? foreignKeyOverride : null; }
/** * Get column overriding, property first, then parent, then holder * replace the placeholder 'collection&&element' with nothing * * These rules are here to support both JPA 2 and legacy overriding rules. * */ public JoinTable getJoinTable(XProperty property) { final String propertyName = StringHelper.qualify( getPath(), property.getName() ); JoinTable result = getOverriddenJoinTable( propertyName ); if (result == null) { result = property.getAnnotation( JoinTable.class ); } return result; }
/** * Get column overriding, property first, then parent, then holder * replace the placeholder 'collection&&element' with nothing * * These rules are here to support both JPA 2 and legacy overriding rules. * */ public JoinColumn[] getOverriddenJoinColumn(String propertyName) { JoinColumn[] result = getExactOverriddenJoinColumn( propertyName ); if ( result == null && propertyName.contains( ".collection&&element." ) ) { //support for non map collections where no prefix is needed //TODO cache the underlying regexp result = getExactOverriddenJoinColumn( propertyName.replace( ".collection&&element.", "." ) ); } return result; }
/** * Get column overriding, property first, then parent, then holder * find the overridden rules from the exact property name. */ private Column[] getExactOverriddenColumn(String propertyName) { Column[] override = null; if ( parent != null ) { override = parent.getExactOverriddenColumn( propertyName ); } if ( override == null && currentPropertyColumnOverride != null ) { override = currentPropertyColumnOverride.get( propertyName ); } if ( override == null && holderColumnOverride != null ) { override = holderColumnOverride.get( propertyName ); } return override; }
public AbstractPropertyHolder( String path, PropertyHolder parent, XClass clazzToProcess, ExtendedMappings mappings ) { this.path = path; this.parent = (AbstractPropertyHolder) parent; this.mappings = mappings; buildHierarchyColumnOverride( clazzToProcess ); }