• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Writing Finder Methods Where Clause

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all...
my intention is to write a finder method which takes an integer parameter(ie Salary) and tries to find the grade of that salary in the SALGRADE table of oracle.(SQL Query for this result is
"Select grade from SALGRADE where 2050 between losal and hisal")
i am using Visual Age for Java 4.0
eth goes fine till I invoke the findGradeForSal method in the Test Client of VAJ...
There i get the following error :
Exception is:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
com.ibm.ejs.persistence.EJSPersistenceException: findSalBetween failed:; nested exception is:
java.lang.NullPointerException
Can Anyone suggest me a work around for this...???
I wrote the following finder method for the above query:
public static final findGradeForSalQueryString ="select T1.Grade from SalGrade T1 where
? >= T1.LoSal and ? <= T1.HiSal"
all other finder methods are working fine...Also
in the ibm-ejb-jar.xmi file the above finder is converted to a perfect SQL statement...
Thanks in Advance...
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think you understand what a Finder method should do. Your query only returns a single column, and if your EJB has only one field, then you've got a serious object design problem. :roll:
Finder methods should return ALL the fields in the database for an EJB -- not just one. A finder method literally means "find the EJB's that match some condition" -- it will, after all, return one ENTIRE EJB or a collection of entire EJB's -- not a partial answer...
So, instead, just use a "WHERE CLAUSE" finder method and only include the WHERE clause portion of your SQL statement. (Information on that is in the InfoCenter, or in my workbook.)
Kyle
[ January 31, 2002: Message edited by: Kyle Brown ]
 
Meghana Reddy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks KYLE for ur help...it worked very fine...
Actually in the begining i wrote the following where clause finder method as
public static final String findGradeForSalWhereClause="? <= T1.HiSal and ? >= T1.LoSal" and i was passing only one parameter to the findGradeForSal in the home interface...so i was getting the error "All Variables not found" when i run the Visual Age Test Client.
i replaced the above query with "between" key word and could make it work...
Thanks KYLE ....Thanks for ur kind help...
Regards
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic