This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Websphere and the fly likes Dynamic query problem in WAS 6.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Dynamic query problem in WAS 6.0" Watch "Dynamic query problem in WAS 6.0" New topic
Author

Dynamic query problem in WAS 6.0

Inthiquab Deen
Greenhorn

Joined: Sep 27, 2005
Posts: 3
I would appreciate if someone will be able to assist us in solving this issue.





The issue is that I have 2 ejb projects say ejbA and ejbB. Let us assume that project ejbA has 2 CMP�s CMP1 and CMP2. Project ejbB has CMP�s CMP1 and CMP2 as well. The Abstract Schema names are not unique in the server scope.







The structure of project ejbA�s CMP1 is



Name String



Description String





The Structure of projects ejbA�s CMP2 is



No Integer



Desc String







The structure of project ejbB�s CMP1 is



Name String



Description String





The Structure of projects ejbB�s CMP2 is



No Integer



Desc String







When I had to execute the query select ejb.* from CMP1 ejb , since there is an ambiguity in the ASN names, it requires the queryDomain parameter. And as mentioned in the docs. I tried the ASN, EJB Home object reference pair.





executeQuery




public QueryIterator executeQuery(java.lang.String queryStatement,
java.lang.Object[] parameterVars,
java.util.Properties queryDomain,
int skipRows,
int maxRows)
throws java.rmi.RemoteException,
QueryException
validate and execute an ejb query statement

Parameters:

queryStatement -

parameterVars - The values to be substituted for any query parameters in the query statement.

queryDomain - Normally a null value. This parameter is null in the cases where the Abstract Schema Names (ASN) used in the query statement are unique in the server scope. If ASN names are not unique across applications in the server, then the ASN name must be qualified by its EJB Home reference. This takes the form of name/value pairs (ASN name, EJB Home object reference). An EJB Home reference can be obtained from a name service lookup call.

skipRows - Number of tuples in the final result set to skip.

maxRows - Maximum number of tuples to return in result set.

Throws:

QueryException - Indicates an invalid query plan, a server or database error occurred, or the query invoked an application method which threw an exception.

java.rmi.RemoteException





/**

* @param filterQuery

* @param whereClauseValues

* @param skipRows

* @param maxRows

* @return

*/

public QueryIterator getQueryResult()

throws RemoteException, NamingException, CreateException,

QueryException {



String qryString = " select ejb.* from CMP1 ejb ";



Properties queryDomain = new Properties();



queryDomain.put("ejb/CMP1", CMP1LocalHome.class);



InitialContext ic = new InitialContext();

QueryHome qh = (QueryHome) ic

.lookup("com/ibm/websphere/ejbquery/Query");

Query qb = qh.create();

QueryIterator it = qb.executeQuery(qryString, null,

queryDomain, 0, 100);



return it;

}





It gives me an error.



The concern is I am not too sure about the format of queryDomain properties file. I would be grateful if you can send me some samples.





Regards



Inthiquab Deen
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamic query problem in WAS 6.0
 
Similar Threads
How to access to a SessionBean in a machine since other SessionBean in other machine
relation between ejb--jar.xml and web.xml?
Problem with Session Facade
Pass by Ref vs Value for a Local EJB that calls a Remote EJB
EJB-QL + wsad