01: /*
02: * User: Michael Rettig
03: * Date: Aug 27, 2002
04: * Time: 12:14:39 AM
05: */
06: package net.sourceforge.jaxor.example.tests;
07:
08: import net.sourceforge.jaxor.MetaRow;
09: import net.sourceforge.jaxor.example.domain.ObjectFactory;
10: import net.sourceforge.jaxor.example.domain.OrdersEntity;
11: import net.sourceforge.jaxor.example.domain.OrdersFinder;
12: import net.sourceforge.jaxor.example.domain.OrdersMetaRow;
13:
14: public class MultiPrimaryKeyTest extends TableTestCase {
15:
16: protected MetaRow getRow() {
17: return new OrdersMetaRow();
18: }
19:
20: public void testUpdatingAndDeleting() {
21: OrdersEntity one = ObjectFactory.createOrder(new Long(123),
22: new Long(1));
23: OrdersEntity two = ObjectFactory.createOrder(new Long(123),
24: new Long(2));
25: commit();
26: assertEquals(2, OrdersFinder.selectByOrderIdList(new Long(123))
27: .size());
28: one = OrdersFinder.selectByPrimaryKey(new Long(123),
29: new Long(1));
30: one.setDescription("new description");
31: commit();
32: OrdersEntity ordersEntity = OrdersFinder.selectByPrimaryKey(
33: new Long(123), new Long(1));
34: assertEquals(new Long(123), ordersEntity.getOrderId());
35: assertEquals(new Long(1), ordersEntity.getCustomerId());
36: assertEquals("new description", ordersEntity.getDescription());
37: assertEquals("desc", OrdersFinder.selectByPrimaryKey(
38: new Long(123), new Long(2)).getDescription());
39: getJaxor().registerDelete(one);
40: commit();
41: assertEquals(1, OrdersFinder.selectByOrderIdList(new Long(123))
42: .size());
43: getJaxor().registerDelete(two);
44: commit();
45: assertEquals(0, OrdersFinder.selectByOrderIdList(new Long(123))
46: .size());
47: }
48:
49: }
|