Of course, I forget to metion the mandatory interfaces:

public interface TestAIF {
}

public interface TestBIF {
}

then

public class TestA implements TestAIF {
}

public class TestB implements TestBIF {
}


Best regards,

Edson Richter
----- Original Message ----- 
From: Edson Carlos Ericksson Richter
To: OJB Users List
Sent: Tuesday, March 23, 2004 3:48 PM
Subject: Re: Newbie Proxy problem


I'll try to do show in a sample:

public class TestA {
  public int idA;
  public java.util.List allB;
}

public class TestB {
  public int idB;
  public int idReferenceToA;
  public TestA referenceToA;
}

in XML:

<class-descriptor
   class="TestA"
   proxy="dynamic"
   table="TB_A">
  <field-descriptor
    name="idA"
    column="ID_A"
    primarykey="true"
    jdbc-type="Integer"/>
    <collection-descriptor
         name="allB"

collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList
"
         element-class-ref="TestB"
         proxy="true"
         auto-update="false"
         auto-delete="false"/>
       <inverse-foreignkey
            field-ref="idReferenceToA"/>
    </collection-descriptor>
</class-descriptor>

<class-descriptor
   class="TestB"
   proxy="dynamic"
   table="TB_B">
  <field-descriptor
    name="idB"
    column="ID_B"
    primarykey="true"
    jdbc-type="Integer"/>
  <field-descriptor
    name="idReferenceToA"
    column="ID_A"
    primarykey="true"
    jdbc-type="Integer"/>
  <reference-descriptor
        name="referenceToA"
        proxy="true"
        class-ref="TestA">
      <foreignkey field-ref="idReferenceToA"/>
    </reference-descriptor>
</class-descriptor>


I get this sample from my projects (just changed the field/table/bean names,
and simplified the beans). This works fine (may be I made some typo when
changing names, so this sample could/couldn't run as is). But the main ideia
is there.

If you are using JavaBeans like acessors (like I do), don't forget to
implement getter/setters for your objects.

Best regards,

Edson Richter
  ----- Original Message ----- 
  From: Mauricio Montblanch
  To: OJB Users List
  Sent: Tuesday, March 23, 2004 3:16 PM
  Subject: Re: Newbie Proxy problem


  Nop, it did not work, have you any example ????????????

  Edson Carlos Ericksson Richter wrote:

  >As far as you have explained, you should not get ClassCastException.
  >First let's go analize your code:
  >
  >1) Product implements InterfaceProduct.
  >2) ProductGroup have a products list. Ok, have you set the
collection-class in the collection-descriptor to ManageableArrayList? If you
have not, do it, because default is RemovalAwareCollection (you can't make
cast from Collection to List, or you will get ClassCastException).
  >
  >Without more details is hard to give you better ideais about what's can
be going wrong.
  >
  >Best regards,
  >
  >Edson Richter
  >
  >  ----- Original Message ----- 
  >  From: Mauricio Montblanch
  >  To: OJB Users List
  >  Sent: Friday, March 19, 2004 11:54 AM
  >  Subject: Newbie Proxy problem
  >
  >
  >  Hi I am trying to use a dynamic proxy in a 1:n relation (loading a
list)
  >  but a I can 't figure out how make it work (I get a
  >  java.lang.ClassCastException when I try to get the any object), can
  >  anyone give me a simple example of how to use a dynamic proxy.
  >
  >  Detail
  >
  >  Clases:
  >
  >  Product
  >  InterfaceProduct (Interface)
  >  ProductGroup (contains List products)
  >
  >  XML:
  >   <class-descriptor class="Product"  proxy="dynamic" table="PRODUCT">
  >  ..............
  >   <class-descriptor class="ProductGroup" table="PRODUCTGROUP">
  >  .....
  >  .....
  >   <collection-descriptor name="products" element-class-ref="Product">
  >   <inverse-foreignkey field-ref="idProductGroup"/>
  >   </collection-descriptor>
  >
  >   so, when y get a product Group y get a list of products filled with
  >  objects of the type (InterfaceProduct)
  >
  >  and I can say
  >
  >  InterfaceProduct  i=(InterfaceProduct)  ptoducts.get(0);
  >  without errors
  >
  >  but how I can materialize the Product Object ????????
  >
  >
  >  ---------------------------------------------------------------------
  >  To unsubscribe, e-mail: [EMAIL PROTECTED]
  >  For additional commands, e-mail: [EMAIL PROTECTED]
  >
  >
  >
  >  ---
  >  Outgoing mail is certified Virus Free.
  >  Checked by AVG anti-virus system (http://www.grisoft.com).
  >  Version: 6.0.624 / Virus Database: 401 - Release Date: 15/3/2004
  >
  >


  ---------------------------------------------------------------------
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]



  ---
  Outgoing mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.637 / Virus Database: 408 - Release Date: 20/3/2004


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.637 / Virus Database: 408 - Release Date: 20/3/2004


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to