Re: Cayenne 3.0M4 ignoring extended data types

From: Chris Gamache (cgamach..mail.com)
Date: Mon Aug 04 2008 - 17:52:54 EDT

  • Next message: Chris Gamache: "Re: Cayenne 3.0M4 ignoring extended data types"

    On Mon, Aug 4, 2008 at 3:32 PM, Andrus Adamchik <andru..bjectstyle.org>wrote:

    >
    > Sure, but can you doublecheck that the types are loaded in the right
    > Configuration? I.e. after all libraries are loaded, can you grab the shared
    > configuration and print the contents of the ExtendedTypeMap?
    >
    > [BTW, this is the area where Cayenne indeed requires some improvement.
    > Support for multi-configuration stack (aka libraries) is coming in 3.0 - I
    > am working on it now.]
    >

    I double checked the types, and they are indeed loaded. I wanted to create a
    set of test cases to illustrate the problem I'm having, and and in doing
    so I found that my cheese has been moved! :)

    Here are the test cases I created:

     private DataContext context;

    ..est
     public void testUser() {

      if(context == null){
       this.context = ContextCreator.makeContext();
      }
      UserTable user = null;
      Expression exp = ExpressionFactory.matchExp(UserTable.USER_UUID_PROPERTY,
    "f7a3f9e2-e94b-4ff7-8b03-4e8549be07cb");
      SelectQuery select = new SelectQuery(UserTable.class, exp);
      user = (UserTable) DataObjectUtils.objectForQuery(context, select);
      if(user == null) throw new IllegalStateException("User not found for user
    f7a3f9e2-e94b-4ff7-8b03-4e8549be07cb");
      try {
       UUID userUuid = user.getUserUuid();
      } catch (ClassCastException e) {
       fail("Failed to retrieve userUuid.");
       return;
      }
      assertTrue(true);

     }
    ..est
     public void testCompany() {

      if(context == null){
       this.context = ContextCreator.makeContext();
      }
      CompanyTable company = null;
      Expression exp =
    ExpressionFactory.matchExp(CompanyTable.COMPANY_UUID_PROPERTY,
    "394fa90e-75a3-4dd1-9205-341409bcba4b");
      SelectQuery select = new SelectQuery(CompanyTable.class, exp);
      company = (CompanyTable) DataObjectUtils.objectForQuery(context, select);
      if(company == null) throw new IllegalStateException("Company not found
    for user 394fa90e-75a3-4dd1-9205-341409bcba4b");
      try {
       UUID companyUuid = company.getCompanyUuid();
      } catch (ClassCastException e) {
       fail("Failed to retrieve companyUuid.");
       return;
      }
      assertTrue(true);

     }

    ..est public void testCompanyFromUser() {
      if(context == null){
       this.context = ContextCreator.makeContext();
      }
      UserTable user = null;
      Expression exp = ExpressionFactory.matchExp(UserTable.USER_UUID_PROPERTY,
    "f7a3f9e2-e94b-4ff7-8b03-4e8549be07cb");
      SelectQuery select = new SelectQuery(UserTable.class, exp);
      user = (UserTable) DataObjectUtils.objectForQuery(context, select);
      if(user == null) throw new IllegalStateException("User not found for user
    f7a3f9e2-e94b-4ff7-8b03-4e8549be07cb");

      try {
       UUID userUuid = user.getUserUuid();
      } catch (ClassCastException e) {
       fail("Failed to retrieve userUuid.");
       return;
      }

      CompanyTable company = user.getToCompanyTable();

      try {
       UUID companyUuid = company.getCompanyUuid();
      } catch (ClassCastException e) {
       fail("Failed to retrieve companyUuid.");
       return;
      }
      assertTrue(true);

     }

    Test #1 and Test #2 fail with the same class cast exception until I remove
    this pair of relations from the config file:

     <db-relationship name="companyTable" source="company_balance_trans_locks"
    target="company_table" toMany="false">
      <db-attribute-pair source="company_uuid" target="company_uuid"/>
     </db-relationship>
     <db-relationship name="creditLocks" source="company_table"
    target="company_balance_trans_locks" toMany="true">
      <db-attribute-pair source="company_uuid" target="company_uuid"/>
     </db-relationship>
     <obj-relationship name="companyTable" source="CompanyBalanceTransLocks"
    target="CompanyTable" db-relationship-path="companyTable"/>
     <obj-relationship name="creditLocks" source="CompanyTable"
    target="CompanyBalanceTransLocks" db-relationship-path="creditLocks"/>
    Then the tests run fine. I'm still baffled, but for a different reason. Why
    would the presence of this relation cause the failure?

    Thank you for continuing to work through this with me.



    This archive was generated by hypermail 2.0.0 : Mon Aug 04 2008 - 17:53:41 EDT