The DB I want to use is something like:
User Table: User_ID ...
User_Action Table: User_ID (fk to User.User_ID, should be one-to-one mapping) ...
So I have this class:
@Entity
@Table(name="User")
public class User {
private long _ID;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "User_ID", nullable = false, unique = true)
public long get_ID() {
return _ID;
}
public void set_ID(long user_ID) {
_ID = user_ID;
}
...
}
and in another class, I have:
@Entity
@Table(name="User_Action")
public class UserAction implements IEntity {
private User _user;
@Id
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "User_ID")
public User get_user() {
return _user;
}
public void set_user(User _user) {
this._user = _user;
}
...
}
However running the code throws the following error in initialization time:
org.hibernate.MappingException: Could not determine type for: mycustom.User, for columns: [org.hibernate.mapping.Column(_user)]
org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
org.hibernate.mapping.RootClass.validate(RootClass.java:193)
org.hibernate.cfg.Configuration.validate(Configuration.java:1099)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1284)
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
...
The hibernate versions I am using are:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
I was suspecting something is wrong with the annoticationConfiguration thing, but not able to confirm it or further debug.. or is it something else?