title: hibernate @ManyToOne no table relationship
body: <p>Currently Using:</p>
  
  <ul>
  <li>Hibernate 4.0.1.Final</li>
  <li>Spring-data-jpa: 1.0.3.RELEASE</li>
  <li>QueryDSL: 2.3.0</li>
  <li>MySQL 5.x</li>
  </ul>
  
  <p>I have an interesting problem that I have not found the answer, or clue for yet.  I have two tables that did not have foreign key or other relationship. But to try and solve this issue I added one. I want my User entity to hold it's UserRole.  This pattern is repeated throughout the database, but this is the easiest to describe.<br>
  Here are my tables:</p>
  
  <p><strong>User</strong></p>
  
  <pre><code>userId           bigint(20) PK
  password         varchar(255)
  status           int(11)
  userName         varchar(255)
  userRoleId       long
  
  
  CONSTRAINT `FK_USERROLE` FOREIGN KEY (`userRoleId`) REFERENCES `UserRole` (`userRoleId`)
  </code></pre>
  
  <p><strong>UserRole</strong></p>
  
  <pre><code>userRoleId       bigint(20) PK
  userRoleDescription varchar(255)
  userRoleDescriptionShort varchar(255)
  </code></pre>
  
  <p>Here are my classes:
  <strong>User.java</strong></p>
  
  <pre><code>import javax.persistence.ElementCollection;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.OneToMany;
  import javax.persistence.Transient;
  import javax.xml.bind.annotation.XmlRootElement;
  @Entity
  @XmlRootElement(name = "User")
  public class User  {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long userId;
  private String password;
  private int status;
  private String userName;
  
  @ManyToOne
  @JoinColumn(name = "userRoleId")
  private UserRole userRole;
  public UserRole getUserRole() {
      return userRole;
  }
  
  public void setUserRole(UserRole userRole) {
      this.userRole = userRole;
  }
  </code></pre>
  
  <p><strong>UserRole.java</strong></p>
  
  <pre><code>@Entity
  @XmlRootElement(name = "userRole")
  public class UserRole {
  private Long userRoleId;
  private String userRoleDescription;
  private String userRoleDescriptionShort;
  
  @ElementCollection
  @OneToMany(mappedBy = "userRole")
  private List&lt;User&gt; users;
  
  public UserRole() {...}
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getUserRoleId() {...    }
  
  @OneToMany(mappedBy = "userRole")
  public List&lt;User&gt; getUsers() {...}
  </code></pre>
  
  <p>So you can see where I am trying to associate the UserRole.userRoleId with the User.  I thought perhaps Hibernate would build the mapping and retrieve/associate the UserRole whenever the User was updated.  </p>
  
  <p>I have gone back and edited this post to use a foreign key between the tables, but on app server startup I get this:</p>
  
  <pre><code>Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: UserRole, for columns: [org.hibernate.mapping.Column(users)]
  at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:304)
  at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:288)
  at org.hibernate.mapping.Property.isValid(Property.java:216)
  at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:467)
  at org.hibernate.mapping.RootClass.validate(RootClass.java:268)
  at org.hibernate.cfg.Configuration.validate(Configuration.java:1287)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1729)
  at org.hibernate.ejb.EntityManagerFactoryImpl.&lt;init&gt;(EntityManagerFactoryImpl.java:84)
  at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
  </code></pre>
  
  <p>I looked for that error, which appears related to JPA and transient variables, which is not the case here.</p>