public WrappedInferredData(PropertyData inferredData, String suffix) { this.wrappedInferredData = inferredData; this.propertyName = StringHelper.qualify( inferredData.getPropertyName(), suffix ); } }
public static String buildSafeClassName(String className, String defaultPackageName) { if ( className.indexOf( '.' ) < 0 && StringHelper.isNotEmpty( defaultPackageName ) ) { className = StringHelper.qualify( defaultPackageName, className ); } return className; }
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 ); } }
log.warn( "Property {} not found in class" + " but described in <mapping-file/> (possible typo error)", StringHelper.qualify( className, propertyName ) );
public static String getPath(PropertyHolder holder, PropertyData property) { return StringHelper.qualify( holder.getPath(), property.getPropertyName() ); }
private static Map<String, Column[]> buildColumnOverride(XAnnotatedElement element, String path) { Map<String, Column[]> columnOverride = new HashMap<String, Column[]>(); if ( element == null ) return columnOverride; AttributeOverride singleOverride = element.getAnnotation( AttributeOverride.class ); AttributeOverrides multipleOverrides = element.getAnnotation( AttributeOverrides.class ); AttributeOverride[] overrides; if ( singleOverride != null ) { overrides = new AttributeOverride[] { singleOverride }; } else if ( multipleOverrides != null ) { overrides = multipleOverrides.value(); } else { overrides = null; } //fill overridden columns if ( overrides != null ) { for (AttributeOverride depAttr : overrides) { columnOverride.put( StringHelper.qualify( path, depAttr.name() ), new Column[] { depAttr.column() } ); } } return columnOverride; }
private static Map<String, JoinColumn[]> buildJoinColumnOverride(XAnnotatedElement element, String path) { Map<String, JoinColumn[]> columnOverride = new HashMap<String, JoinColumn[]>(); if ( element == null ) return columnOverride; AssociationOverride singleOverride = element.getAnnotation( AssociationOverride.class ); AssociationOverrides multipleOverrides = element.getAnnotation( AssociationOverrides.class ); AssociationOverride[] overrides; if ( singleOverride != null ) { overrides = new AssociationOverride[] { singleOverride }; } else if ( multipleOverrides != null ) { overrides = multipleOverrides.value(); } else { overrides = null; } //fill overridden columns if ( overrides != null ) { for (AssociationOverride depAttr : overrides) { columnOverride.put( StringHelper.qualify( path, depAttr.name() ), depAttr.joinColumns() ); } } return columnOverride; }
/** * 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; }
private static Map<String, JoinTable> buildJoinTableOverride(XAnnotatedElement element, String path) { Map<String, JoinTable> tableOverride = new HashMap<String, JoinTable>(); if ( element == null ) return tableOverride; AssociationOverride singleOverride = element.getAnnotation( AssociationOverride.class ); AssociationOverrides multipleOverrides = element.getAnnotation( AssociationOverrides.class ); AssociationOverride[] overrides; if ( singleOverride != null ) { overrides = new AssociationOverride[] { singleOverride }; } else if ( multipleOverrides != null ) { overrides = multipleOverrides.value(); } else { overrides = null; } //fill overridden tables if ( overrides != null ) { for (AssociationOverride depAttr : overrides) { if ( depAttr.joinColumns().length == 0 ) { tableOverride.put( StringHelper.qualify( path, depAttr.name() ), depAttr.joinTable() ); } } } return tableOverride; }
private String getCondition(String cond, String name) { if ( BinderHelper.isDefault( cond ) ) { cond = mappings.getFilterDefinition( name ).getDefaultFilterCondition(); if ( StringHelper.isEmpty( cond ) ) { throw new AnnotationException( "no filter condition found for filter " + name + " in " + StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); } } return cond; }
public void assertTypesAreResolvable(AccessType access) { TreeMap<String, XProperty> xprops; if ( AccessType.PROPERTY.equals( access ) || AccessType.DEFAULT.equals( access ) ) { xprops = propertyAccessMap; } else { xprops = fieldAccessMap; } for ( XProperty property : xprops.values() ) { if ( !property.isTypeResolved() && !discoverTypeWithoutReflection( property ) ) { String msg = "Property " + StringHelper.qualify( xClass.getName(), property.getName() ) + " has an unbound type and no explicit target entity. Resolve this Generic usage issue" + " or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type"; throw new AnnotationException( msg ); } } }
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 ); /* * HbmBinder 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 ) { ( (OneToOne) value ).createForeignKey(); } else { throw new AssertionFailure( "FkSecondPass for a wrong value type: " + value.getClass().getName() ); } } }
) { JoinColumn[] actualColumns = propertyHolder.getOverriddenJoinColumn( StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); if ( actualColumns == null ) actualColumns = anns;
if ( property.isAnnotationPresent( CollectionId.class ) ) { throw new AnnotationException( "Set do not support @CollectionId: " + StringHelper.qualify( entityName, property.getName() ) ); if ( property.isAnnotationPresent( CollectionId.class ) ) { throw new AnnotationException( "Set do not support @CollectionId: " + StringHelper.qualify( entityName, property.getName() ) ); if ( property.isAnnotationPresent( CollectionId.class ) ) { throw new AnnotationException( "Map do not support @CollectionId: " + StringHelper.qualify( entityName, property.getName() ) ); if ( property.isAnnotationPresent( CollectionId.class ) ) { throw new AnnotationException( "Map do not support @CollectionId: " + StringHelper.qualify( entityName, property.getName() ) ); throw new AnnotationException( "List do not support @CollectionId and @OrderColumn (or @IndexColumn) at the same time: " + StringHelper.qualify( entityName, property.getName() ) ); throw new AnnotationException( returnedClass.getName() + " collection not yet supported: " + StringHelper.qualify( entityName, property.getName() ) ); throw new AnnotationException( "Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: " + StringHelper.qualify( entityName, property.getName() ) );
+ StringHelper.qualify( propertyHolder.getPath(), propertyName ) );
throw new AnnotationException( "@Generated(INSERT) on a @Version property not allowed, use ALWAYS: " + StringHelper.qualify( holder.getPath(), name ) ); throw new AnnotationException( "@OptimisticLock.exclude=true incompatible with @Id, @EmbeddedId and @Version: " + StringHelper.qualify( holder.getPath(), name ) );
+ StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() ) );
throw new AnnotationException( "Illegal use of @FilterJoinTable on an association without join table:" + StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); throw new AnnotationException( "Illegal use of @FilterJoinTable on an association without join table:" + StringHelper.qualify( propertyHolder.getPath(), propertyName ) ); throw new AnnotationException( "Illegal use of @WhereJoinTable on an association without join table:" + StringHelper.qualify( propertyHolder.getPath(), propertyName ) );
javax.persistence.Column[] actualCols = anns; javax.persistence.Column[] overriddenCols = propertyHolder.getOverriddenColumn( StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() ) ); if ( overriddenCols != null ) {
PropertyHolder valueHolder = PropertyHolderBuilder.buildPropertyHolder( this.collection, StringHelper.qualify( this.collection.getRole(), "key" ), (XClass) null, (XProperty) null, propertyHolder, mappings