java.lang.IllegalStateException

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.

  • The following: @Embedded MyClass<MyGeneric> getMyClass(){ return myClass; } will result and exception: java.lang.IllegalStateException: Property myClass has an unbound type and no explicit target entity. at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:938) at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:788) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:614) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:226) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:160) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1068) at org.apache.tools.ant.Main.runBuild(Main.java:668) at org.apache.tools.ant.Main.startAnt(Main.java:187) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:17)
    via by Michael Kantarovich,
  • The following: @Embedded MyClass<MyGeneric> getMyClass(){ return myClass; } will result and exception: java.lang.IllegalStateException: Property myClass has an unbound type and no explicit target entity. at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:938) at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:788) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:614) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:226) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:160) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1068) at org.apache.tools.ant.Main.runBuild(Main.java:668) at org.apache.tools.ant.Main.startAnt(Main.java:187) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:17)
    via by Michael Kantarovich,
  • @Transient properties should probably always be ignored by Hibernate. In the case of this bug, it is not. Here's an example: public class Foo<T> { private int id; @Id public int getId() { return id; } public void setId(int id) { this.id = id; } @Transient public Foo<T> getFoo() { return this; } } The getFoo() method will cause the following error: Exception in thread "main" java.lang.IllegalStateException: Property moderationRuleHandler has an unbound type and no explicit target entity. at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:873) at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:727) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:561) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:295) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:216) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1172) The code looks like this: for ( XProperty p : properties ) { if( !p.isTypeResolved() && !hasExplicitTargetEntity( p ) ) throw new IllegalStateException( "Property " + p + " has an unbound type and no explicit target entity."); final boolean currentHasIdentifier = addProperty( p, elements, localPropertyAccessor ); hasIdentifier = hasIdentifier || currentHasIdentifier; } It might need to be something like this instead: for ( XProperty p : properties ) { if(mustBeSkipped(p)) { continue; } if( !p.isTypeResolved() && !hasExplicitTargetEntity( p ) ) throw new IllegalStateException( "Property " + p + " has an unbound type and no explicit target entity."); final boolean currentHasIdentifier = addProperty( p, elements, localPropertyAccessor ); hasIdentifier = hasIdentifier || currentHasIdentifier; }
    via by Brian Lenz,
  • When a collection is mapped using @ManyToOne or @CollectionOfElements, the entity in the collection is derived from the parametrised type of the collection. e.g. there is no need to explicitly indicate the elements of the following collection are books. @ManyToOne Set<Book> books; It would be nice if the same kind of discovery could be applied to Embeddable types when contained in a CollectionOfElements. E.g. it would be nice if Hibernate could derive that the embedded Versioned references a Book in the example below @CollectionOfElements Set<Versioned<Book>>; @Embeddable class Versioned<T> { T rightSide; Date date; } Even if it wasn't derived, it would be good to be able to specify it. Currently the only way to make the above work is to create a subclass of Versioned that explicitly binds the type parameter to Book. Without this the below exception is thrown while building the session factory Exception in thread "main" java.lang.IllegalStateException: Property rightSide has an unbound type and no explicit target entity. at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:946) at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:1655) at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1054) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:543) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:484) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43) at org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:377) at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1476) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:706) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1210)
    via by Edward Costello,
  • @Transient properties should probably always be ignored by Hibernate. In the case of this bug, it is not. Here's an example: public class Foo<T> { private int id; @Id public int getId() { return id; } public void setId(int id) { this.id = id; } @Transient public Foo<T> getFoo() { return this; } } The getFoo() method will cause the following error: Exception in thread "main" java.lang.IllegalStateException: Property moderationRuleHandler has an unbound type and no explicit target entity. at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:873) at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:727) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:561) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:295) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:216) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1172) The code looks like this: for ( XProperty p : properties ) { if( !p.isTypeResolved() && !hasExplicitTargetEntity( p ) ) throw new IllegalStateException( "Property " + p + " has an unbound type and no explicit target entity."); final boolean currentHasIdentifier = addProperty( p, elements, localPropertyAccessor ); hasIdentifier = hasIdentifier || currentHasIdentifier; } It might need to be something like this instead: for ( XProperty p : properties ) { if(mustBeSkipped(p)) { continue; } if( !p.isTypeResolved() && !hasExplicitTargetEntity( p ) ) throw new IllegalStateException( "Property " + p + " has an unbound type and no explicit target entity."); final boolean currentHasIdentifier = addProperty( p, elements, localPropertyAccessor ); hasIdentifier = hasIdentifier || currentHasIdentifier; }
    via by Brian Lenz,
  • When a collection is mapped using @ManyToOne or @CollectionOfElements, the entity in the collection is derived from the parametrised type of the collection. e.g. there is no need to explicitly indicate the elements of the following collection are books. @ManyToOne Set<Book> books; It would be nice if the same kind of discovery could be applied to Embeddable types when contained in a CollectionOfElements. E.g. it would be nice if Hibernate could derive that the embedded Versioned references a Book in the example below @CollectionOfElements Set<Versioned<Book>>; @Embeddable class Versioned<T> { T rightSide; Date date; } Even if it wasn't derived, it would be good to be able to specify it. Currently the only way to make the above work is to create a subclass of Versioned that explicitly binds the type parameter to Book. Without this the below exception is thrown while building the session factory Exception in thread "main" java.lang.IllegalStateException: Property rightSide has an unbound type and no explicit target entity. at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:946) at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:1655) at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1054) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:543) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:484) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43) at org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:377) at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1476) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:706) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1210)
    via by Edward Costello,
    • java.lang.IllegalStateException: Property myClass has an unbound type and no explicit target entity. at org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(AnnotationBinder.java:938) at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:788) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:614) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:226) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:160) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1068) at org.apache.tools.ant.Main.runBuild(Main.java:668) at org.apache.tools.ant.Main.startAnt(Main.java:187) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:17)
    No Bugmate found.