This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Multiple Primary Keys Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Multiple Primary Keys" Watch "Multiple Primary Keys" New topic
Author

Multiple Primary Keys

tan kian
Ranch Hand

Joined: Apr 09, 2004
Posts: 40
how do i do this in j2ee? for example,i want sid,pid and cid to be the primary keys. do i specify something like this in the localHome?

public EnrolLocal create(String sid,String currentsem,String pid,String cid) throws CreateException,RemoteException;
public EnrolLocal findByPrimaryKey(String sid) throws FinderException;
public EnrolLocal findByPrimaryKey(String pid) throws FinderException;
public EnrolLocal findByPrimaryKey(String cid) throws FinderException;

or like this:

public EnrolLocal findSid(String sid) throws FinderException;
public EnrolLocal findPid(String pid) throws FinderException;
public EnrolLocal findCid(String cid) throws FinderException;
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2038
nope, your complex key will be an object
tan kian
Ranch Hand

Joined: Apr 09, 2004
Posts: 40
so should it be like this?
public EnrolLocal create(String sid,String currentsem,String pid,String cid,MixedKey multipleKey) throws CreateException,RemoteException;
public EnrolLocal findByPrimaryKey(MixedKey multipleKey) throws FinderException;

and multipleKey will be something like this:
public MixedKey(String sid,String pid,String cid)
[ September 10, 2005: Message edited by: tan kian ]
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2038
to be sure, you may have to check the book,

in addition, you will need to learn how to create the complex key object, there are methods that must be in the class, e.g. i think one method is on hash
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Multiple Primary Keys
 
Similar Threads
urgent
public Collection findByGenre(String Genre) throws **FinderException**..
Error in retrieivng Primary Key
Checked exception - NoSuchObjectException & ObjectNotFoundException
Error: [ ejbFindByPrimaryKey ]