This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Finder Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Finder Methods" Watch "Finder Methods" New topic
Author

Finder Methods

chin josei
Greenhorn

Joined: Jun 22, 2001
Posts: 25
hii..
I have a CMP bean whichz having couple of finder methods.
The finder methods always returns the first row in the table.
Irrespective of whatever input i give, say for example..
findByPrimaryKey(new Key(""XX"))
findByPrimaryKey(new Key("YY"))
boh returns the same first row in the table.
Now this problem happens only if I use a Primary Class of my own.
If I use a String Object as my Primary Key itz working perfectly.
what mistake am i doing?
thanx in advance
chin
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
Can you show th code for ejbFindByPrimaryKey()
and the key object class.


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
trevershick
Greenhorn

Joined: Apr 23, 2001
Posts: 6
What App server are you using?
Weblogic?
What's your deployment descriptor like?

Originally posted by chin josei:
hii..
I have a CMP bean whichz having couple of finder methods.
The finder methods always returns the first row in the table.
Irrespective of whatever input i give, say for example..
findByPrimaryKey(new Key(""XX"))
findByPrimaryKey(new Key("YY"))
boh returns the same first row in the table.
Now this problem happens only if I use a Primary Class of my own.
If I use a String Object as my Primary Key itz working perfectly.
what mistake am i doing?
thanx in advance
chin

Matt Midcap
Sheriff

Joined: Jan 07, 1999
Posts: 440
"trevershick",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
[This message has been edited by Matt Midcap (edited July 03, 2001).]


Best Regards,<br />Matt Midcap
vijay shepunde
Greenhorn

Joined: Jul 13, 2001
Posts: 1
Originally posted by Matt Midcap:
"trevershick",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
[This message has been edited by Matt Midcap (edited July 03, 2001).]

Normally it happens when you use findByPrimaryKey method against a Non-Unique database fields, ie if there are more than one records by same name/value, it always returns first record
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Finder Methods