title: NullPointerException org.hibernate.cfg.OneToOneSecondPass.doSecondPass
body: <p>I am using Hibernate 3.0</p>
  
  <p>I have the following tables and corresponding entries,</p>
  
  <pre><code>Table A:
  Integer aid;
  Integer bid;
  
  Table B:
  Integer bid;
  
  @Entity
  @Table(name="A")
  public class A {
  
  @Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  @Column(name="aid")
  Integer AId;
  @OneToOne(targetEntity=B.class)
  @JoinColumn(name="bid", referencedColumnName="bid")
  B b;
  }
  
  
  @Entity
  @Table(name="B")
  public class B {
  
  @Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  @Column(name="bid")
  Integer bId;
  
  @OneToOne(targetEntity=A.class, mappedBy="b")
  @JoinColumn(referencedColumnName="bid")
  A a;
  }
  </code></pre>
  
  <p>When I try to run my spring application with the above configuration, I get the following error,</p>
  
  <pre><code>Caused by: java.lang.NullPointerException
      at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:135)
      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1163)
      at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316)
      at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)
      at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:720)
      at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
  </code></pre>
  
  <p>&nbsp;</p>
  
  <p>I need reference of A in B, even though B is not having any reference for A.</p>