Object model:
MyOrder is a class that has a field of type OrderLine (as a collection).
I saved two MyOrder objects into a database.
order1 references 2 OrderLine objects.
order2 references 3 OrderLine objects.
If I select all MyOrder objects, the OrderLine objects of the order2 are
always removed from the data base when do transaction commit(even I do give
MyOrder
objects permanent references). Do I have any way to avoid this?
Thanks very much in advance!
java code:
--------------------------------------------------------------
public void run( PrintWriter writer)
throws Exception
{
Database db;
OQLQuery orderOql;
QueryResults results;
System.out.println(".....get database");
db = _jdo.getDatabase();
Vector outOrders = new Vector();
Vector ols = new Vector();
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
+ ")");
outOrders.add((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