Dear all,
I am working in OJB with Oracle DB,i can execute the following query
public class......
......
......
String oqlQuery="select * from " + AddFormForm.class.getName()+" where prod_type
like $1";
......
......
......
But i am not able excute
String oqlQuery="select * from " + AddFormForm.class.getName()+" where prod_type in
($1)";
Tried code as follows:
package com.cit.ojb;
import org.apache.ojb.odmg.*;
import org.odmg.*;
import java.util.*;
public class TestODMGServices
{
public TestODMGServices() {
}
public static void main(String[] dhamu)
{
/*get odmg facade instance*/
Implementation odmg = OJB.getInstance();
Database db= odmg.newDatabase();
java.util.Iterator iter=null;
try
{
/*my query request by my product type */
String bindVar="03454E,2233R";
/*open database*/
db.open("repository.xml", Database.OPEN_READ_WRITE);
/*open a transaction*/
Transaction tx = odmg.newTransaction();
tx.begin();
/*get an OQLQuery object from the ODMG facade*/
OQLQuery query = odmg.newOQLQuery();
/*set the OQL select statement*/
String oqlQuery="select product from " + AddFormForm.class.getName()+"
where prod_type in($1)";
query.create(oqlQuery);
/*binding my product type value*/
query.bind(bindVar);
/*perform the query and store the result in a persistent Collection*/
List allDetails = (List)query.execute();
tx.commit();
/*now iterate over the result to print each product*/
iter = allDetails.iterator();
while(iter.hasNext())
{
/*my own class mapped in repository_user.xml*/
AddFormForm product=(AddFormForm)iter.next();
System.out.println("Product Name = "+product.getName());
}
}
catch (ODMGException ex)
{
ex.printStackTrace();
}
}
}
Thanks in Advance
Dhamufunction SetDomain(d) { document.domain = d; }
---------------------------------
Get a bigger mailbox -- choose a size that fits your needs.