Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic queries in weblogic

Status
Not open for further replies.

rons4174

Programmer
Aug 15, 2002
2
US
In case of dynamic queries, I found out that the finder method can not be defined in the Home class. I defined the finder

method in the Bean.

In my Bean, this is the code:

public Collection findAllActivities(String filter, Object[] arguments) throws FinderException
{
Properties myProp = new Properties();

for(int i = 0; i < arguments.length; i++)
{
myProp.setProperty(String.valueOf(i), String.valueOf((arguments)));
}

try
{
InitialContext ic = new InitialContext();
RolesHome rh = (RolesHome)ic.lookup(&quot;RolesHome&quot;);
QueryHome qh = (QueryHome)rh;

String weblogicQL = &quot;SELECT DISTINCT OBJECT(o) FROM roles AS o&quot; + filter;

Query query = qh.createQuery();

return query.find(weblogicQL, myProp);
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}

I get a naming exception if I use : RolesHome rh = (RolesHome)ic.lookup(&quot;RolesHome&quot;);

javax.naming.NameNotFoundException: Unable to resolve 'RolesHome' Resolved: '' Unresolved:'RolesHome' ; remaining name

'RolesHome'

I get a casting exception if I use: RolesHome rh = (RolesHome)ic.lookup(&quot;Roles&quot;);


In my jsp file:

I have this code

InitialContext jndiContext = new InitialContext();
Object obj = jndiContext.lookup(&quot;Roles&quot;);
RolesHome rolesHome = (RolesHome) obj;
list = (ArrayList) rolesHome.findAllActivities(filter, filterParams);

but the problem is that the home interface does not contain the findAllActivities function. I have already defined rolesHome

earlier in the code which I want to use for findAllActivities also. I can not cast the bean e.g. RolesBean rolesBean = (

RolesBean) rolesHome. I do not want to create a new bean as I am already using an old rolesHome. How do I solve this

problem??? Please do let me know. I am really confused.

Thanks
Ronak Parekh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top