Dear Neil,Jane & Hoang,

           Those are seeking for simple OQL where syntax, following is the example.If 
you have any doubts just reply me.

Regards

Dhamu

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)
 {
   file://get odmg facade instance
  Implementation odmg = OJB.getInstance();
  Database db= odmg.newDatabase();
   java.util.Iterator iter=null;
      try
        {
            file://my primary key
    String bindVar="3";

            file://open database
            db.open("repository.xml", Database.OPEN_READ_WRITE);

            file://open a transaction
            Transaction tx = odmg.newTransaction();
            tx.begin();

            file://get an OQLQuery object from the ODMG facade
            OQLQuery query = odmg.newOQLQuery();

            file://set the OQL select statement
            String oqlQuery="select product from " + AddFormForm.class.getName()+" 
where eid=$1";
            System.out.println(oqlQuery);
            query.create(oqlQuery);
            file://binding my primary key value
            query.bind(bindVar);

            // 4. perform the query and store the result in a persistent Collection
            List allDetails = (List)query.execute();
            tx.commit();

            file://now iterate over the result to print each product
                  iter = allDetails.iterator();

                  while(iter.hasNext())
                  {
         file://my own class mapped in repository_user.xml
                  AddFormForm product=(AddFormForm)iter.next();
                  System.out.println("Name of the product = "+product.getName());

                  }


        }
        catch (ODMGException ex)
        {
            ex.printStackTrace();
        }

 }
 }

 




---------------------------------
Get a bigger mailbox -- choose a size that fits your needs.

Reply via email to