2 Replies Latest reply on Oct 15, 2007 1:27 PM by Marius Oancea

    seam-gen problem when same table is referenced two times

    Marius Oancea Novice

      I have a table USER and a table ADDRESS.

      USER has two (important) attributes :
      - localAddress
      - remoteAddress

      both are foreign keys to ADDRESS table.

      So in ADDRESS table we will have two records for each user.

      seam generate-entities perfectly generate the beans but home entities are wrong. Name of address home entities injected in user home have the same name.

      create table xx.user (
       userid varchar(10)NOT NULL PRIMARY KEY,
       local_address integer,
       remote_address integer
      ) in userspace1;
      create table xx.ADDRESS (
       adrid integer NOT NULL PRIMARY KEY,
       street varchar(200),
       streetNo integer
      ) in userspace1;
      alter table xx.user add CONSTRAINT ADR1 foreign key (local_address) references xx.ADDRESS(adrid);
      alter table xx.user add CONSTRAINT ADR2 foreign key (remote_address) references xx.ADDRESS(adrid);

      Entity user is good:
      @Table(name = "USER", schema = "xx")
      public class User implements java.io.Serializable {
       private String userid;
       private Address addressByLocalAddress; //<---- correct, different names
       private Address addressByRemoteAddress; //<---- correct, different names

      but in UserHome we have:
      public class UserHome extends EntityHome<User> {
       @In(create = true)
       AddressHome addressHome; //<----- WRONG, SAME NAME
       @In(create = true)
       AddressHome addressHome; //<----- WRONG, SAME NAME

      I'm using SEAM 2.0 BETA (Hibernate Tools 3.2.0.b9) with ant.

      Any clue?