This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I found following paragraphs in the book 'Enterprise Java Beans' by Monson-Haefel -
An undefined primary key allows the deployer to choose a system-specific key at deployment time. For example, An object database, uses a completely different mechanism for indexing objects, to which a primary key may not map well. To facilitate the use of undefined primary keys, the CMP bean class and its interfaces use the Object type to identify the primary key. The findByPrimaryKey() method defined in the local and remote home interfaces must also use an Object type. The deployment descriptor defines its primary key type as java.lang.Object and does not define any <prim-key-field> elements it's not possible to construct an undefined primary key to use in a find method if you don't know its type.
Now my question is: the developer does not define EJB QL for findByPrimaryKey() method. It is done by the container automatically. So in case of undefined primary key, how does the container provide the implemenation for findByPrimaryKey() if the primary key itself is undefined? Moreover, findByPrimaryKey() method has to be present in home interface of an entity bean, so who provides it's implementation? how does the container map the Object type primary key to the underlying data source specific primary key?
Joined: Aug 07, 2001
Nobody is there to answer this ??? where r the moderators gone? is this a very silly question to ask, so nobody wants to answer ???
It is not a miracle that a post goes unanswered even for days, some posts never get answered. I don't think your question has anything wrong -- it's just a difficult question, I guess. By the way, the moderators are not gods and it's not their job to see that every question gets answered...
By the way, the moderators are not gods and it's not their job to see that every question gets answered... I never say moderartors are god...its just that i was getting curious to know the answer...and the question was not just for moderators, it was for all the friendly ranchers...so why r u getting angry? when i said ... where r the moderators gone? i never meant that they dont have any meaningful work and their sole responsibility is to answer our silly questions...ppl like Valentine and Rob ross have always helped me during my SCJP ...so may be i was taking u moderartors granted to answer qustions all the time. but, hey, thanks for letting us know the moderator's responsibility, so that here after i would never count on the immediate help from moderators. may be ppl like me have unreasonable expectations from this friendly ranch... [ December 17, 2003: Message edited by: Rashmi Tambe ]
Joined: Jan 23, 2002
I apologise. I didn't mean that comment to be a hostile gesture. I should've included the smiley. Sorry.
You may take a closer look at: http://www.woronowicz.com/books/javaenterprise/ebeans/ch06_01.htm I haven't found a clear explanation on this subject but this is my opinion: in CMP you never provide the implementation for findByPrimaryKey() and this is always implemented by the container. This option of using "undefined primary key" was introduced in order for the bean not to be dependent on the (object) database used and depending on this the container may map different types to the primary key. So you implement the bean and then the container selects the primary key for you. Inside the local home interface the findByPrimaryKey declaration is like this: public BeanLocal findByPrimaryKey(Object primaryKey) throws javax.ejb.FinderException; The drawback on this is that you can not use the findByPrimaryKey() inside your code because you cannot be sure of the type used for the primary key. If you find more let us know.
Sergiu : thanks for the link. I did not know that the old edition of the book was freely accessible on the site. Rashmi: Your question is in fact a difficult question. I think EJB Projects which use an undefined primary key is quite rare. Atleast I have not heard/come across one. Most of the EJB projects use relational databases like Oracle, SQL Server and DB2. Most of the times, we know what the primary key is(either simple or compound and its mapping to the relevant columns in the database) during the design phase itself... But do not give up your hopes...some rancher from the delta quadrant, who knows the answer might bump into our galaxy...you never know...
Joined: Aug 07, 2001
thnx vish and Sergiu . Sergiu , i open the link...its the same book mentioned but the older edition. It says the same thing i mentioned...but does not answer my question anyways, thanks... i hope some body can answer this...