gdamour     2005/07/09 09:33:39

  Modified:    
modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetoone
                        OneToOneTest.java
  Log:

  It is now possible to set the value of a CMP field mapped to a FK column, in
  other words a CMR field. The previous implementation was only allowing for a
  read access.
  
  Note that in the case of a CMP field mapped to a CMR field related to an EJB
  having a compound PK, the implementation is still read-only.
  
  Revision  Changes    Path
  1.5       +9 -7      
openejb/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetoone/OneToOneTest.java
  
  Index: OneToOneTest.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/test/org/openejb/deployment/entity/cmp/cmr/onetoone/OneToOneTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- OneToOneTest.java 17 May 2005 15:49:38 -0000      1.4
  +++ OneToOneTest.java 9 Jul 2005 13:33:38 -0000       1.5
  @@ -299,7 +299,7 @@
   

           Connection c = ds.getConnection();

           Statement s = c.createStatement();

  -        ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM A");

  +        ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM A WHERE A1 = 1");

           assertTrue(rs.next());

           assertEquals(0, rs.getInt(1));

           rs.close();

  @@ -320,11 +320,12 @@
           TransactionContext ctx = newTransactionContext();

           BLocal b = bhome.findByPrimaryKey(new Integer(11));

   

  -        try {

  -            b.setField3(new Integer(13));

  -            fail("Cannot set the value of a CMP field mapped to a foreign 
key column.");

  -        } catch (EJBException e) {

  -        }

  +        b.setField3(new Integer(2));

  +

  +        ALocal a = b.getA();

  +        assertEquals(new Integer(2), a.getField1());

  +        assertEquals("value2", a.getField2());

  +        

           ctx.commit();

       }

   

  @@ -352,6 +353,7 @@
           s.execute("CREATE TABLE B(B1 INTEGER, B2 VARCHAR(50), FKA1 
INTEGER)");

           

           s.execute("INSERT INTO A(A1, A2) VALUES(1, 'value1')");

  +        s.execute("INSERT INTO A(A1, A2) VALUES(2, 'value2')");

           s.execute("INSERT INTO B(B1, B2, FKA1) VALUES(11, 'value11', 1)");

           s.close();

           c.close();

  
  
  

Reply via email to