private void validateBind() { if ( property.isAnnotationPresent( Immutable.class ) ) { throw new AnnotationException( "@Immutable on property not allowed. " + "Only allowed on entity level or on a collection." ); } if ( !declaringClassSet ) { throw new AssertionFailure( "declaringClass has not been set before a bind" ); } }
public PersistentClass getPersistentClassHostingProperties(MappedSuperclassTypeImpl<?> mappedSuperclassType) { final PersistentClass persistentClass = mappedSuperClassTypeToPersistentClass.get( mappedSuperclassType ); if ( persistentClass == null ) { throw new AssertionFailure( "Could not find PersistentClass for MappedSuperclassType: " + mappedSuperclassType.getJavaType() ); } return persistentClass; }
public static MappedSuperclass getMappedSuperclassOrNull( XClass declaringClass, Map<XClass, InheritanceState> inheritanceStatePerClass, MetadataBuildingContext context) { boolean retrieve = false; if ( declaringClass != null ) { final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass ); if ( inheritanceState == null ) { throw new org.hibernate.annotations.common.AssertionFailure( "Declaring class is not found in the inheritance state hierarchy: " + declaringClass ); } if ( inheritanceState.isEmbeddableSuperclass() ) { retrieve = true; } } if ( retrieve ) { return context.getMetadataCollector().getMappedSuperclass( context.getBootstrapContext().getReflectionManager().toClass( declaringClass ) ); } else { return null; } }
if ( property.isAnnotationPresent( MapKeyColumn.class ) && mapKeyPropertyName != null ) { throw new AnnotationException( collection.setMutable( !property.isAnnotationPresent( Immutable.class ) ); final OptimisticLock lockAnn = property.getAnnotation( OptimisticLock.class ); final boolean includeInOptimisticLockChecks = ( lockAnn != null ) ? ! lockAnn.excluded() Persister persisterAnn = property.getAnnotation( Persister.class ); if ( persisterAnn != null ) { collection.setCollectionPersisterClass( persisterAnn.impl() ); SQLInsert sqlInsert = property.getAnnotation( SQLInsert.class ); SQLUpdate sqlUpdate = property.getAnnotation( SQLUpdate.class ); SQLDelete sqlDelete = property.getAnnotation( SQLDelete.class ); SQLDeleteAll sqlDeleteAll = property.getAnnotation( SQLDeleteAll.class ); Loader loader = property.getAnnotation( Loader.class ); if ( sqlInsert != null ) { collection.setCustomSQLInsert( sqlInsert.sql().trim(), sqlInsert.callable(), && (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: "; && property.isAnnotationPresent( OnDelete.class ) && !property.isAnnotationPresent( JoinColumn.class )) {
private void defineFetchingStrategy() { LazyCollection lazy = property.getAnnotation( LazyCollection.class ); Fetch fetch = property.getAnnotation( Fetch.class ); OneToMany oneToMany = property.getAnnotation( OneToMany.class ); ManyToMany manyToMany = property.getAnnotation( ManyToMany.class ); ElementCollection elementCollection = property.getAnnotation( ElementCollection.class ); ManyToAny manyToAny = property.getAnnotation( ManyToAny.class ); FetchType fetchType; if ( oneToMany != null ) { throw new AssertionFailure( "Define fetch strategy on a property not annotated with @ManyToOne nor @OneToMany nor @CollectionOfElements" ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
throw new AssertionFailure( "CollectionSecondPass for oneToMany should not be called with null mappings" ); oneToMany.setReferencedEntityName( collectionType.getName() ); oneToMany.setIgnoreNotFound( ignoreNotFound );
final PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( collType.getName() ); final String hqlOrderBy = extractHqlOrderBy( jpaOrderBy ); ManyToAny anyAnn = property.getAnnotation( ManyToAny.class ); if ( LOG.isDebugEnabled() ) { String path = collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName(); if ( property.isAnnotationPresent( ManyToMany.class ) || property.isAnnotationPresent( OneToMany.class ) ) { String path = collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName(); throw new AnnotationException( associationTableBinder.setJPA2ElementCollection( !isCollectionOfEntities && property.isAnnotationPresent( ElementCollection.class )); collValue.setCollectionTable( associationTableBinder.bind() ); element = new ManyToOne( buildingContext, collValue.getCollectionTable() ); collValue.setElement( element ); element.setReferencedEntityName( collType.getName() ); final ForeignKey fk = property.getAnnotation( ForeignKey.class ); if ( fk != null && !BinderHelper.isEmptyAnnotationValue( fk.name() ) ) { element.setForeignKeyName( fk.name() ); final JoinTable joinTableAnn = property.getAnnotation( JoinTable.class ); if ( joinTableAnn != null ) { String foreignKeyName = joinTableAnn.inverseForeignKey().name(); if ( BinderHelper.PRIMITIVE_NAMES.contains( collType.getName() ) ) { classType = AnnotatedClassType.NONE; elementClass = null;
public static MappedSuperclass getMappedSuperclassOrNull(XClass declaringClass, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings) { boolean retrieve = false; if ( declaringClass != null ) { final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass ); if ( inheritanceState == null ) { throw new org.hibernate.annotations.common.AssertionFailure( "Declaring class is not found in the inheritance state hierarchy: " + declaringClass ); } if ( inheritanceState.isEmbeddableSuperclass() ) { retrieve = true; } } return retrieve ? mappings.getMappedSuperclass( mappings.getReflectionManager().toClass( declaringClass ) ) : null; }
public void popEntityWorkedOn(PersistentClass persistentClass) { final PersistentClass stackTop = stackOfPersistentClassesBeingProcessed.remove( stackOfPersistentClassesBeingProcessed.size() - 1 ); if ( stackTop != persistentClass ) { throw new AssertionFailure( "Inconsistent popping: " + persistentClass.getEntityName() + " instead of " + stackTop.getEntityName() ); } }
private void validateBind() { if ( property.isAnnotationPresent( Immutable.class ) ) { throw new AnnotationException( "@Immutable on property not allowed. " + "Only allowed on entity level or on a collection." ); } if ( !declaringClassSet ) { throw new AssertionFailure( "declaringClass has not been set before a bind" ); } }
private String getStringBasedPath(Path.Node traversableProperty, Path pathToTraversableObject) { StringBuilder path = new StringBuilder( ); for ( Path.Node node : pathToTraversableObject ) { if (node.getName() != null) { path.append( node.getName() ).append( "." ); } } if ( traversableProperty.getName() == null ) { throw new AssertionFailure( "TraversableResolver being passed a traversableProperty with null name. pathToTraversableObject: " + path.toString() ); } path.append( traversableProperty.getName() ); return path.toString(); }
/** * Constructs a JarProtocolArchiveDescriptor * * @param archiveDescriptorFactory The factory creating this * @param url The url to the JAR file * @param incomingEntry The prefix for entries within the JAR url */ public JarProtocolArchiveDescriptor( ArchiveDescriptorFactory archiveDescriptorFactory, URL url, String incomingEntry) { if ( incomingEntry != null && incomingEntry.length() > 0 ) { throw new IllegalArgumentException( "jar:jar: not supported: " + url ); } final String urlFile = url.getFile(); final int subEntryIndex = urlFile.lastIndexOf( "!" ); if ( subEntryIndex == -1 ) { throw new AssertionFailure( "JAR URL does not contain '!/' :" + url ); } final String subEntry; if ( subEntryIndex + 1 >= urlFile.length() ) { subEntry = ""; } else { subEntry = urlFile.substring( subEntryIndex + 1 ); } final URL fileUrl = archiveDescriptorFactory.getJarURLFromURLEntry( url, subEntry ); delegateDescriptor = archiveDescriptorFactory.buildArchiveDescriptor( fileUrl, subEntry ); }
private Class<?> getClassFromGenericArgument(java.lang.reflect.Type type) { if ( type instanceof Class ) { return (Class) type; } else if ( type instanceof TypeVariable ) { final java.lang.reflect.Type upperBound = ( (TypeVariable) type ).getBounds()[0]; return getClassFromGenericArgument( upperBound ); } else if ( type instanceof ParameterizedType ) { final java.lang.reflect.Type rawType = ( (ParameterizedType) type ).getRawType(); return getClassFromGenericArgument( rawType ); } else if ( type instanceof WildcardType ) { final java.lang.reflect.Type upperBound = ( (WildcardType) type ).getUpperBounds()[0]; return getClassFromGenericArgument( upperBound ); } else { throw new AssertionFailure( "Fail to process type argument in a generic declaration. Member : " + getMemberDescription() + " Type: " + type.getClass() ); } }
private void addPropertyToPersistentClass(Property prop, XClass declaringClass) { if ( declaringClass != null ) { final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass ); if ( inheritanceState == null ) { throw new AssertionFailure( "Declaring class is not found in the inheritance state hierarchy: " + declaringClass ); } if ( inheritanceState.isEmbeddableSuperclass() ) { persistentClass.addMappedsuperclassProperty(prop); addPropertyToMappedSuperclass( prop, declaringClass ); } else { persistentClass.addProperty( prop ); } } else { persistentClass.addProperty( prop ); } }
private void addPropertyToJoin(Property prop, XClass declaringClass, Join join) { if ( declaringClass != null ) { final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass ); if ( inheritanceState == null ) { throw new AssertionFailure( "Declaring class is not found in the inheritance state hierarchy: " + declaringClass ); } if ( inheritanceState.isEmbeddableSuperclass() ) { join.addMappedsuperclassProperty(prop); addPropertyToMappedSuperclass( prop, declaringClass ); } else { join.addProperty( prop ); } } else { join.addProperty( prop ); } }
throw new AssertionFailure( "Unable to inject static metamodel attribute : " + metamodelClass.getName() + '#' + name,
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 ); } }
throw new AssertionFailure( "Unexpected mapping type: " + mapping.getClass() );
private String getStringBasedPath(Path.Node traversableProperty, Path pathToTraversableObject) { StringBuilder path = new StringBuilder( ); for ( Path.Node node : pathToTraversableObject ) { if (node.getName() != null) { path.append( node.getName() ).append( "." ); } } if ( traversableProperty.getName() == null ) { throw new AssertionFailure( "TraversableResolver being passed a traversableProperty with null name. pathToTraversableObject: " + path.toString() ); } path.append( traversableProperty.getName() ); return path.toString(); }
throw new AssertionFailure( "Unknown type : " + typeContext.getValueClassification() );