Hi all,
I am new to hibernate and just in the beginning I got a little problem. We have an old database and in one table the pk is an integer and in the other table the fk is a bigint.
As soon as I am using a OneToMany and ManyToOne relation I got the following exception: [code] Caused by: org.hibernate.HibernateException: Wrong column type: refid, expected: integer at org.hibernate.mapping.Table.validateColumns(Table.java:261) at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1083) at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713) ... 136 more [/code]
These are the entities: [code] @Entity @Table(name="PERSON") public class Person { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="personId") private int id; @ManyToOne @JoinColumn(name="refid") private Address address; } [/code]
[code] @Entity @Table(name = "ADDRESS") public class Address {
@Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "addressId") private int id;
@OneToMany(mappedBy="address") @Column(name="personId") private Set<Person> people; } [/code]
It would be very nice if someone could help me. By the way, it is not possible to change a column the database :(
Greetings, arres
|