permaculture playing cards*
The moose likes EJB and other Java EE Technologies and the fly likes finder method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "finder method" Watch "finder method" New topic
Author

finder method

Devaki Nihar
Greenhorn

Joined: Apr 30, 2005
Posts: 20
I am using Orion2.0 App server.I used CMP entitybeans.I have written one finder method
My code is like this
1) in TestUserHome home interface of entity beans
public Collection findByFirstName(String firstName)throws FinderException , RemoteException;
2) in ejb-jar.xml
<entity>
<display-name>TestUser</display-name>
<ejb-name>TestUser</ejb-name>
<home>myPackage.TestUserHome</home>
<remote>myPackage.TestUser</remote>
<ejb-class>myPackage.TestUserEJB</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>myPackage.TestUserPK</prim-key-class>
<reentrant>False</reentrant>
<abstract-schema-name>TestUser</abstract-schema-name>
<cmp-field>
<field-name>UserID</field-name>
</cmp-field>
<cmp-field>
<field-name>firstName</field-name>
</cmp-field>
<cmp-field>
<field-name>lastName</field-name>
</cmp-field>
<!------ And more other -->
<resource-ref>
<description></description>
<res-ref-name>jdbc/MyDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<query>
<query-method>
<method-name>findByFirstName</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
SELECT OBJECT(u) FROM TestUser AS u WHERE u.firstName=?1
</ejb-ql>
</query>
</entity>

3) I am calling the finder method from session bean as
///////Other required stuff here
Collection testUsers =testUserHome.findByFirstName(name);
////////other stuff

And when i execute the application then it gets all the records regardless of the finding by the passed name
But when i do entry in server specific orion-ejb-jar.xml as

<entity-deployment name="TestUser" location="TestUser" wrapper="TestUserHome_EntityHomeWrapper2"
table="TestUser" data-source="jdbc/MyDS" isolation="uncommitted" max-tx-retries="2">
<finder-method query="$firstName = $1">
<method>
<ejb-name>TestUser</ejb-name>
<method-name>findByFirstName</method-name>
<method-params>
<method-param>String</method-param>
</method-params>
</method>
</finder-method>
</entity-deployment>

IT RUNS OK
but both cases i get one warning when i start my server as
WARNING: Unused <query> tag found in <entity> 'TestUser', method name 'findByFirstName(java.lang.String)'
Stephan Staeheli
Greenhorn

Joined: Jul 22, 2002
Posts: 27
Hi there

I never worked with orion, so I just have to guess: Is there some kind of 'orion-cmp-rdbms-jar.xml' that maps the cmp-fields to real database fields? In WebLogic I have such thing and there I also have to register my finder methods. Have a look in your docu for 'cmp-rdbms', hope this helps.

Stephan
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
This may be useful.
http://www.coderanch.com/t/316838/EJB-JEE/java/Trouble-understanding-abstract-schema-name


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Devaki Nihar
Greenhorn

Joined: Apr 30, 2005
Posts: 20
There is no any config file such like 'orion-cmp-rdbms-jar.xml'
And already i have mapped all the cmp fields in deployment descriptor.
THE APPLICATION IS WORKING FINE but i am getting the warning at server startup.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: finder method