Tabnine Logo
org.hibernate.annotations.common
Code IndexAdd Tabnine to your IDE (free)

How to use org.hibernate.annotations.common

Best Java code snippets using org.hibernate.annotations.common (Showing top 20 results out of 315)

origin: hibernate/hibernate-orm

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" );
  }
}
origin: hibernate/hibernate-orm

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;
}
origin: hibernate/hibernate-orm

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;
  }
}
origin: hibernate/hibernate-orm

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 )) {
origin: hibernate/hibernate-orm

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() );
origin: hibernate/hibernate-orm

  throw new AssertionFailure(
      "CollectionSecondPass for oneToMany should not be called with null mappings"
  );
oneToMany.setReferencedEntityName( collectionType.getName() );
oneToMany.setIgnoreNotFound( ignoreNotFound );
origin: hibernate/hibernate-orm

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;
origin: org.hibernate/hibernate-annotations

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;
}
origin: hibernate/hibernate-orm

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()
    );
  }
}
origin: org.hibernate/hibernate-annotations

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" );
  }
}
origin: hibernate/hibernate-orm

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();
}
origin: hibernate/hibernate-orm

/**
 * 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 );
}
origin: hibernate/hibernate-orm

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()
    );
  }
}
origin: hibernate/hibernate-orm

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 );
  }
}
origin: hibernate/hibernate-orm

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 );
  }
}
origin: hibernate/hibernate-orm

throw new AssertionFailure(
    "Unable to inject static metamodel attribute : " + metamodelClass.getName() + '#' + name,
origin: hibernate/hibernate-orm

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 );
  }
}
origin: hibernate/hibernate-orm

throw new AssertionFailure( "Unexpected mapping type: " + mapping.getClass() );
origin: org.hibernate/hibernate-annotations

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();
}
origin: hibernate/hibernate-orm

throw new AssertionFailure( "Unknown type : " + typeContext.getValueClassification() );
org.hibernate.annotations.common

Most used classes

  • JavaReflectionManager
    The factory for all the objects in this package.
  • ReflectionManager
    The entry point to the reflection layer (a.k.a. the X* layer).
  • XClass
  • AnnotationDescriptor
    Encapsulates the data you need to create an annotation. In particular, it stores the type of an Anno
  • AnnotationFactory
    Creates live annotations (actually AnnotationProxies) from AnnotationDescriptors .
  • ReflectionUtil,
  • MetadataProvider,
  • XProperty,
  • AssertionFailure,
  • XAnnotatedElement,
  • MetadataProviderInjector,
  • XMethod,
  • XPackage,
  • ReflectHelper,
  • AnnotationProxy,
  • AnnotationReader,
  • JavaMetadataProvider,
  • TypeEnvironment,
  • TypeEnvironmentFactory
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now