title: org.hibernate.MappingException: Unable to find column with logical name OnetoOne Mapping
body: <p>I'm newb to JPA. I'm having trouble with defining OneToOne bidirectional flow on my classes. </p>
  
  <p>UserInfo.java: </p>
  
  <pre><code>@Entity
  @Table(name="UserInfo")
  public class UserInfo {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Integer idUserInfo;
  private String firstName;
  private String lastName;
  
  
  @OneToOne(mappedBy="UserInfo")
  private LoginInfo loginInfo;
  </code></pre>
  
  <p>LoginInfo.java: </p>
  
  <pre><code>@Entity
  @Table(name="LoginInfo")
  public class LoginInfo {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Integer idLoginInfo;
  
  @Column(name="emailId")
  private String emailId;
  
  //bidirectional one to one association to UserInfo
  @OneToOne
  @JoinColumn(name="emailId", referencedColumnName="loginInfo")
  private UserInfo userInfo;
  
  
  private String sessionId;
  private String password;
  </code></pre>
  
  <p>Here's sql to create those tables:</p>
  
  <pre><code>   CREATE TABLE `LoginInfo` (
       `emailId` varchar(45) NOT NULL,
       `idLoginInfo` int(11) NOT NULL AUTO_INCREMENT,
       PRIMARY KEY (`idLoginInfo`),
       UNIQUE KEY `emailId_UNIQUE` (`emailId`),
       UNIQUE KEY `id_UNIQUE` (`idLoginInfo`)
     );
  
     DROP TABLE IF EXISTS `UserInfo`;
      CREATE TABLE `UserInfo` (
        `idUserInfo` int(11) NOT NULL AUTO_INCREMENT,
        `firstName` varchar(45) NOT NULL,
        `lastName` varchar(45) NOT NULL,
        `loginInfo` varchar(45) NOT NULL,
        PRIMARY KEY (`idUserInfo`),
        UNIQUE KEY `idUserInfo_UNIQUE` (`idUserInfo`),
        UNIQUE KEY `loginInfo_UNIQUE` (`loginInfo`),
        CONSTRAINT `loginInfo` FOREIGN KEY (`loginInfo`) REFERENCES `LoginInfo` (`emailId`) ON DELETE CASCADE ON UPDATE CASCADE
        ); 
  </code></pre>
  
  <p>When I start the Tomcat server, I'm getting the follow exception on ContextInitialization. </p>
  
  <pre><code>Caused by: org.hibernate.MappingException: Unable to find column with logical name: loginInfo in org.hibernate.mapping.Table(UserInfo) and its related supertables and secondary tables
  </code></pre>
  
  <p>But the column do exist on the UserInfo table. Can somebody please help me if the mapping is right? </p>
  
  <p>Thanks</p>