0 Replies Latest reply on Oct 19, 2007 6:09 AM by David Spark

    Mapping relationship where database ID's are different forma

    David Spark Newbie

      I'm trying to map a OneToOne relationship in a legacy database. The problem I have is that I keep getting the following error:

      javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: LocationID, expected: tinyint
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:737)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
       at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)...


      My entity beans are setup as follows:
      @Entity
      @Table(name="tblAccountManager")
      public class AccountManager implements Serializable {
      
      ...
      
       @OneToOne
       @JoinColumn(name="LocationID")
       private Branch branch;


      @Entity
      @Table(name="web_location")
      @Name("Branch")
      public class Branch implements Serializable {
      
       private static final long serialVersionUID = -7280892867401735383L;
      
       @Id @GeneratedValue
       @Column(name = "Loc_ID")
       @org.hibernate.annotations.Type(type = "custom.hibernate.IntegerToByteUserType")
       private Integer id;


      I guess the problem is that in the database tblAccountManager.LocationID is an int(11) where as web_location.Loc_ID is a tinyint(3). Is there any way to map this setup with annotations and without changing the database?