• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

finder method  RSS feed

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)'
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be useful.
http://www.coderanch.com/t/316838/EJB-JEE/java/Trouble-understanding-abstract-schema-name
 
Devaki Nihar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!