users@glassfish.java.net

jdbc realm Entites modeling question

From: Felipe Gaścho <fgaucho_at_gmail.com>
Date: Sat, 22 Aug 2009 19:45:59 +0200

all over the jdbc realm samples I grabbed on the web shown a db script
like that:

create table usertable(userid varchar(10) not null, password
varchar(32) not null, primary key(userid));
create table grouptable(userid varchar(10) not null, groupid
varchar(20) not null, primary key(userid));
alter table grouptable add constraint FK_USERID foreign key(userid)
references usertable(userid);


I was wondering how to create JPA entities to model such tables
without restricting 1 user to pertain to only 1 group ..

my last attempt (using this code, I am restricted to only 1 to 1 userXgroup:

@Entity
@Table(name = "USERTABLE")
public class PujUserRef extends AbstractArenaEntity {
        @XmlElement
        @Id
        private String login;
...
}


@Entity
@Table(name = "GROUPTABLE")
public class PujGroupEntity extends AbstractArenaEntity {
        @Id
        @JoinColumn(table = "USERTABLE", referencedColumnName = "LOGIN",
unique = false)
        private String login;

        @XmlElement
        @Column(name = "GROUPID", nullable = false)
        private String groupId;
...
}

-- 
Looking for a client application for this service:
http://fgaucho.dyndns.org:8080/footprint-service/wadl