A primary key i *A* primary key. You can only have one! If the key to a
UserList is a specific combination of a userId and a listId, then they
together are the primary key. Hence you can only have one constructor in
your PK class.
Instead you should have 2 more finders:
Collection findByUserId(UserId userId);
Collection findByListId(ListId listId);
jBoss will implement them magically only you have them in you home
interface!
/Lennart
Indika Fernando skrev:
>
> thanks Alexander,
>
> If I have to find only by the userID primarykey
> or only by the listID primary key?.......................
>
> what if I have 3 contructors in the UserListPK
> like this...
>
> public UserListPK(String userID)
> {
> this.userID = userID;
> }
> public UserListPK(String listID)
> {
> this.listID = listID;
> }
> public UserListPK(String userID,String listID)
> {
> this.userID = userID;
> this.listID = listID;
>
> }
> .....
> will it work????
> and what shall I specify in the deployment descripter..
> shall I specify both as primary...
>
> tia
> indi..
>
> ----- Original Message -----
> From: "Alexander Klyubin" <[EMAIL PROTECTED]>
> To: "jBoss" <[EMAIL PROTECTED]>
> Sent: Thursday, January 18, 2001 1:00 PM
> Subject: RE: [jBoss-User] how to have COMPOSITE PRIMARY KEYS in jboss CMP.
>
> > Create a UserListPK and use it as your primary key. There are some caveats
> > though, you'll have to implemet equals() and hashCode() methods correctly.
> >
> > public class UserListPK
> > {
> > public String userID;
> > public String listID;
> >
> > ...
> > }
> >
> >
> > When it's done, you just declare:
> > public UserList findByPrimaryKey(UserListPK id) throws
> > FinderException, RemoteException;
> >
> > Alexander Klyubin
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Indika Fernando
> > Sent: Thursday, January 18, 2001 08:32
> > To: [EMAIL PROTECTED]
> > Subject: [jBoss-User] how to have COMPOSITE PRIMARY KEYS in jboss CMP.
> >
> >
> > Hey all,
> > I am using jboss CMP beans and I have an entity bean called a UserList and
> > in this I have two container managed fields called userID and listID ,these
> > two are composite primary keys....
> > My quection is how jboss will find this....
> > in the UserListHome how should I include the methods ...
> >
> > will this work with jboss:
> > public UserList findByPrimaryKey(String userID,String listID) throws
> > FinderException, RemoteExceptio
> n;
> >
> > indi...(expecting a quick reply).
> >
> >
> >
> > --
> > --------------------------------------------------------------
> > To subscribe: [EMAIL PROTECTED]
> > To unsubscribe: [EMAIL PROTECTED]
> > List Help?: [EMAIL PROTECTED]
> >
> >
> >
> > --
> > --------------------------------------------------------------
> > To subscribe: [EMAIL PROTECTED]
> > To unsubscribe: [EMAIL PROTECTED]
> > List Help?: [EMAIL PROTECTED]
> >
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> List Help?: [EMAIL PROTECTED]
--
mailto:[EMAIL PROTECTED]
http://www.benefit.se/english
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]