Hi, 
        I have a problem by using JDO and need helps. Thanks in advance for
any replies.
        With JDO, I created two order objects (of class MyOrder) and stored
into an oracle database.
The MyOrder class has a collection field with the type of class Orderline.
Now I can select
the order objects and get orderLine objects that belong to an order objects.
Everything works
fine.

        Now if I start another application (a new java VM) and select all
order objects, the orderLine objects
of the second order will be removed from the database when the transaction
commits. If I have 4 orders,
the orderlines of the 4th order will be removed when do commit. Anybody can
help me out this?

--------------------------------------------------------------
 java code:
--------------------------------------------------------------
 public void run( PrintWriter writer)
        throws Exception
    {
        Database      db;
                OQLQuery orderOql;
                QueryResults  results;
                System.out.println(".....get database");
                db = _jdo.getDatabase();
                        db.begin();
                        int k=0;
                        orderOql = db.getOQLQuery( "SELECT o FROM
com.MyOrder o");
                        results = orderOql.execute();
                        
                        while ( results.hasMore() ) {
                                k++;
                                System.out.println( ".......add order(" + k
+ ")");
                                MyOrder order = (MyOrder) results.next());
                        }
        
                        results.close();
                        orderOql.close();
                        System.out.println(".....do commit");
                        db.commit();
                        
                db.close();
        }

--------------------------------------------------------------
output
---------------------------------------------------------------------
.....get database

[test] SELECT
"ORDERS"."ID","ORDERS"."NAME","ORDERS"."CUSTOMER","ORDER_LINE"."ID" FROM
"ORDER_LINE","ORDERS" WHERE "ORDERS"."ID"="ORDER_LINE"."ORDER_ID"(+)
[test] Castor: Loading com.Customer (101)
[test] Castor: Loading com.OrderLine (1)
[test] Castor: Loading com.OrderLine (2)
[test] Castor: Loading com.MyOrder (1)
.......add order(1)
[test] Castor: Loading com.Customer (202)
[test] Castor: Loading com.OrderLine (3)
[test] Castor: Loading com.OrderLine (4)
[test] Castor: Loading com.OrderLine (5)
[test] Castor: Loading com.MyOrder (2)
.......add order(2)
.....do commit
[test] Castor: Removing com.OrderLine (3)****why removed?
[test] Castor: Removing com.OrderLine (4)****why removed?
[test] Castor: Removing com.OrderLine (5)****why removed?

Notes:
If I have 4 orders, the orderLines of the 4th order will be removed!


----------------------------------------------------------------------- 
Ping Ding 

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to