org.hibernate.AnnotationException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I have implemented a custom QuotingNamingStrategy that quotes table names, so that they are properly treated as case sensitive and to avoid issues with reserved names. I also have auxiliary "Table" annotations to have Hibernate create indexes on my behalf. Of course the table name is not quoted in these annotations: {code} @org.hibernate.annotations.Table(appliesTo="MyTable",indexes = { @Index(name="column1", columnNames="column2")}) {code} Now I get the exception: {noformat} org.hibernate.AnnotationException: @org.hibernate.annotations.Table references an unknown table: MyTable at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:877) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733) {noformat} Debugging the issue, I find that the EntityBinder tries to match the quoted name against the "appliesTo" attribute of the Table annotation, but the value of this attribute is not processed by my custom QuotingNamingStrategy. Thus, the table cannot be found: {code} public void processComplementaryTableDefinitions(org.hibernate.annotations.Table table) { //comment and index are processed here if ( table == null ) return; String appliedTable = table.appliesTo(); Iterator tables = persistentClass.getTableClosureIterator(); Table hibTable = null; while ( tables.hasNext() ) { Table pcTable = (Table) tables.next(); // -=> Here the quoted name is compared to the unquoted name from "appliedTable" if ( pcTable.getQuotedName().equals( appliedTable ) ) { //we are in the correct table to find columns hibTable = pcTable; break; } hibTable = null; } if ( hibTable == null ) { //maybe a join/secondary table for ( Join join : secondaryTables.values() ) { if ( join.getTable().getQuotedName().equals( appliedTable ) ) { hibTable = join.getTable(); break; } } } if ( hibTable == null ) { throw new AnnotationException( "@org.hibernate.annotations.Table references an unknown table: " + appliedTable ); } if ( !BinderHelper.isEmptyAnnotationValue( table.comment() ) ) hibTable.setComment( table.comment() ); TableBinder.addIndexes( hibTable, table.indexes(), mappings ); } {code} I do believe that the value of the "appliedTo" attribute should be passed through the naming strategy before comparing against the table name.
    via by Richard Eckart de Castilho,
  • No identifier specified for entity
    via Stack Overflow by Magick
    ,
  • I have implemented a custom QuotingNamingStrategy that quotes table names, so that they are properly treated as case sensitive and to avoid issues with reserved names. I also have auxiliary "Table" annotations to have Hibernate create indexes on my behalf. Of course the table name is not quoted in these annotations: {code} @org.hibernate.annotations.Table(appliesTo="MyTable",indexes = { @Index(name="column1", columnNames="column2")}) {code} Now I get the exception: {noformat} org.hibernate.AnnotationException: @org.hibernate.annotations.Table references an unknown table: MyTable at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:877) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733) {noformat} Debugging the issue, I find that the EntityBinder tries to match the quoted name against the "appliesTo" attribute of the Table annotation, but the value of this attribute is not processed by my custom QuotingNamingStrategy. Thus, the table cannot be found: {code} public void processComplementaryTableDefinitions(org.hibernate.annotations.Table table) { //comment and index are processed here if ( table == null ) return; String appliedTable = table.appliesTo(); Iterator tables = persistentClass.getTableClosureIterator(); Table hibTable = null; while ( tables.hasNext() ) { Table pcTable = (Table) tables.next(); // -=> Here the quoted name is compared to the unquoted name from "appliedTable" if ( pcTable.getQuotedName().equals( appliedTable ) ) { //we are in the correct table to find columns hibTable = pcTable; break; } hibTable = null; } if ( hibTable == null ) { //maybe a join/secondary table for ( Join join : secondaryTables.values() ) { if ( join.getTable().getQuotedName().equals( appliedTable ) ) { hibTable = join.getTable(); break; } } } if ( hibTable == null ) { throw new AnnotationException( "@org.hibernate.annotations.Table references an unknown table: " + appliedTable ); } if ( !BinderHelper.isEmptyAnnotationValue( table.comment() ) ) hibTable.setComment( table.comment() ); TableBinder.addIndexes( hibTable, table.indexes(), mappings ); } {code} I do believe that the value of the "appliedTo" attribute should be passed through the naming strategy before comparing against the table name.
    via by Richard Eckart de Castilho,
  • Hello everyone, Storage json in Mysql DB
    via Stack Overflow by marie
    ,
    • org.hibernate.AnnotationException: Collection has neither generic type or OneToMany.targetEntity() defined: my.package.papertest at org.hibernate.cfg.annotations.CollectionBinder.getCollectionType(CollectionBinder.java:347) at org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:304) at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1208) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:651)

    Users with the same issue

    slashslash
    8 times, last one,
    tvrmsmithtvrmsmith
    2 times, last one,
    AxeloAxelo
    3 times, last one,
    PilleoPilleo
    2 times, last one,
    CasperCasper
    7 times, last one,
    15 more bugmates