java.lang.NullPointerException

Hibernate JIRA | Loïc Minier | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Hi, (Note: I originally reported this on the forum, but the lack of response suggests this might be a bug in Hibernate Annotations or Hibernate; the forum topic is at: http://forum.hibernate.org/viewtopic.php?t=970823) I hope it's not a misuse of Hibernate, but I'm trying to use @Id on @OneToOne, and this causes the following NPE when running hbm2ddl: java.lang.NullPointerException at org.hibernate.util.StringHelper.qualify(StringHelper.java:264) at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:196) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:287) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:171) 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) What I'm trying to do at the application level is: Foo class and table long foo_id, primary key FooData fooData, nulllable=true FooData class and table foo_id references Foo(foo_id), nullable=false This is expressed in Java as: @Entity @Table(name = "foo") public class Foo { @Id @GeneratedValue @Column(name = "foo_id") Long id; @OneToOne(mappedBy = "foo", cascade = CascadeType.ALL) FooData fooData; ... @Entity @Table(name = "foo_data") public class FooData { @Id @OneToOne @JoinColumn(name = "foo_id", nullable = false) Foo foo; This causes a NPE here. If I use a real Id on FooData, e.g.: @Id @Column(name = "foo_data_id") Long id; it works, and I end up with: - foo_id in table foo as a primary key - foo_data_id in table foo_data as a primary key - foo_id in table foo_data not null - foo_id in table foo_data references foo_id in table foo I don't want a foo_data_id, I don't need it, hence the lack of it which leads to the NPE. Bye,

    Hibernate JIRA | 1 decade ago | Loïc Minier
    java.lang.NullPointerException
  2. 0

    Hi, (Note: I originally reported this on the forum, but the lack of response suggests this might be a bug in Hibernate Annotations or Hibernate; the forum topic is at: http://forum.hibernate.org/viewtopic.php?t=970823) I hope it's not a misuse of Hibernate, but I'm trying to use @Id on @OneToOne, and this causes the following NPE when running hbm2ddl: java.lang.NullPointerException at org.hibernate.util.StringHelper.qualify(StringHelper.java:264) at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:196) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115) at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56) at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:287) at org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45) at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:171) 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) What I'm trying to do at the application level is: Foo class and table long foo_id, primary key FooData fooData, nulllable=true FooData class and table foo_id references Foo(foo_id), nullable=false This is expressed in Java as: @Entity @Table(name = "foo") public class Foo { @Id @GeneratedValue @Column(name = "foo_id") Long id; @OneToOne(mappedBy = "foo", cascade = CascadeType.ALL) FooData fooData; ... @Entity @Table(name = "foo_data") public class FooData { @Id @OneToOne @JoinColumn(name = "foo_id", nullable = false) Foo foo; This causes a NPE here. If I use a real Id on FooData, e.g.: @Id @Column(name = "foo_data_id") Long id; it works, and I end up with: - foo_id in table foo as a primary key - foo_data_id in table foo_data as a primary key - foo_id in table foo_data not null - foo_id in table foo_data references foo_id in table foo I don't want a foo_data_id, I don't need it, hence the lack of it which leads to the NPE. Bye,

    Hibernate JIRA | 1 decade ago | Loïc Minier
    java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.hibernate.util.StringHelper.qualify()
    2. Hibernate
      StringHelper.qualify
      1. org.hibernate.util.StringHelper.qualify(StringHelper.java:264)
      1 frame
    3. Hibernate
      Configuration.buildMappings
      1. org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:196)
      2. org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
      3. org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
      4. org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
      4 frames
    4. A Hibernate O/RM Module
      HibernateToolTask.execute
      1. org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:56)
      2. org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:287)
      3. org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hbm2DDLExporterTask.java:45)
      4. org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:171)
      4 frames
    5. Ant
      Main.startAnt
      1. org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      2. org.apache.tools.ant.Task.perform(Task.java:364)
      3. org.apache.tools.ant.Target.execute(Target.java:341)
      4. org.apache.tools.ant.Target.performTasks(Target.java:369)
      5. org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
      6. org.apache.tools.ant.Project.executeTarget(Project.java:1185)
      7. org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
      8. org.apache.tools.ant.Project.executeTargets(Project.java:1068)
      9. org.apache.tools.ant.Main.runBuild(Main.java:668)
      10. org.apache.tools.ant.Main.startAnt(Main.java:187)
      10 frames
    6. Apache Ant Launcher
      Launcher.main
      1. org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
      2. org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
      2 frames