You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Thomas Papke <we...@thopap.de> on 2004/12/04 16:33:31 UTC

Problem with n:m association

Hello ...

i have a problem with a n:m association in my example application.

I have a class productgroup "Produktgruppe" and a class product 
"Produkt". The productgroup should hold a collection of products, but a 
product could be in more than one productgroup. So i have a n:m association.

I have build 3 tables:
Produktgruppe with id, name, inid [inid because of 1:n association of 
the productgroups itself]
Produkt with id, name
Produkt_produktgruppe with produkt_id, produktgruppe_id

I have written the descriptor. If i start my application only with 
productgroups - everthing works perfect. I could also insert a product, 
which is correctly written to database. But if i restart my application 
i got:

java.lang.ArithmeticException: / by zero
    at 
org.apache.ojb.broker.accesslayer.BasePrefetcher.<init>(BasePrefetcher.java:76)
    at 
org.apache.ojb.broker.accesslayer.RelationshipPrefetcherImpl.<init>(RelationshipPrefetcherImpl.java:39)
    at 
org.apache.ojb.broker.accesslayer.CollectionPrefetcher.<init>(CollectionPrefetcher.java:60)
    at 
org.apache.ojb.broker.accesslayer.RelationshipPrefetcherFactory.createRelationshipPrefetcher(RelationshipPrefetcherFactory.java:46)
    at 
org.apache.ojb.broker.core.QueryReferenceBroker.performRetrievalTasks(QueryReferenceBroker.java:328)
    at 
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:167)
    at 
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:233)
    at 
org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryReferenceBroker.java:253)
    at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1217)
    at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:338)
    at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:338)
    at de.ba.studi.chtp.model.Portal.getProduktgruppen(Portal.java:122)
...

Here is my descriptor of the two classes:

<class-descriptor
    class="de.ba.studi.chtp.model.Produktgruppe"
    table="Produktgruppe"
 >
    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
    >
    </field-descriptor>
    <field-descriptor
        name="inId"
        column="inId"
        jdbc-type="INTEGER"
    >
    </field-descriptor>
    <field-descriptor
        name="name"
        column="name"
        jdbc-type="VARCHAR"
    >
    </field-descriptor>
    <collection-descriptor
       name="produktgruppen"
       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
       orderby="inId"
       sort="DESC"
       auto-retrieve="true"
       auto-update="true"
       auto-delete="true"
    >
       <inverse-foreignkey field-ref="inId"/>
    </collection-descriptor>
    <collection-descriptor
       name="produkt"
       element-class-ref="de.ba.studi.chtp.model.Produkt"
       auto-retrieve="true"
       auto-update="true"
       indirection-table="produkt_produktgruppe"
  >
       <fk-pointing-to-this-class column="ProdGruppe_id"/>
       <fk-pointing-to-element-class column="Prod_Id"/>
  </collection-descriptor>
</class-descriptor>

<class-descriptor
    class="de.ba.studi.chtp.model.Produkt"
    table="Produkt"
 >
    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
    >
    </field-descriptor>
    <field-descriptor
        name="name"
        column="name"
        jdbc-type="VARCHAR"
    >
    </field-descriptor>

 
  <collection-descriptor
       name="meinung"
       element-class-ref="de.ba.studi.chtp.model.Meinung"
       auto-retrieve="true"
       auto-update="true"
  >
       <inverse-foreignkey field-ref="prod_id"/>
  </collection-descriptor>
   
</class-descriptor>


Could anyone help?

Thanks, Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Armin Waibel <ar...@apache.org>.
Thomas Papke wrote:

> Ok i have solved the problem.
> 
> There was no pk defined for my class called "meinung", because i develop 
> step by step and meinung was not yet complet (i found this with some 
> more debugging infos in ojb). So in detail there was not problem with my 
> n:m association.
> 
> So thanks for your help....
> But here you see that a better error message should occur - not only 
> devide by zero.
>

ok, will try add a better error message.

regards,
Armin


> Thomas
> 
> Armin Waibel schrieb:
> 
>>
>> Thomas Papke wrote:
>>
>>> Hi ...
>>>
>>> yes that could be the problem. For the tables "Produktgruppe" and 
>>> "Produkt", i have defined the primary keys in the deskriptor. The 
>>> table for decompose the n:m mapping "produkt_produktgruppe" - i have 
>>> nothing defined in the descriptor.
>>
>>
>>
>> As you are using a non-decomposed m:n relation the indirection table 
>> "produkt_produktgruppe" couldn't be a persistent class, so you 
>> shouldn't define a class-descriptor for the indirection table or set 
>> the FK fields from product and group as PK fields.
>>
>> regards,
>> Armin
>>
>>
>>> Because as described in the docs of ojb 
>>> http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
>>> it should work.
>>>
>>> Did i something wrong?
>>> On the bottom of this email again the interessting parts of my 
>>> descriptor where you could see that i have defined the pk's for 
>>> produktgruppe and produkt in a correct way.
>>>
>>> Is the possibly a bug of ojb or is something necessary what is not 
>>> mentioned in the example for n:m ojb mapping?
>>>
>>> Thanks, Thomas
>>>
>>> Armin Waibel schrieb:
>>>
>>>> Hi Thomas,
>>>>
>>>> Thomas Papke wrote:
>>>>
>>>>> The excectly exception (after broker.getCollectionByQuery ...) i 
>>>>> got from ojb broker is:
>>>>>
>>>>> org.apache.ojb.broker.PersistenceBrokerException: 
>>>>> java.lang.ArithmeticException: / by zero
>>>>>
>>>>
>>>> In the source the causing line is
>>>>
>>>> at BasePrefetcher.<init>(BasePrefetcher.java:76)
>>>> ...
>>>> pkLimit = getPrefetchInLimit() / 
>>>> getItemClassDescriptor().getPkFields().length;
>>>> ...
>>>>
>>>> Seems that OJB get a persistent class without defined PK fields. 
>>>> Could this be the case?
>>>>
>>>> regards,
>>>> Armin
>>>>
>>>>
>>>>> Thomas Papke schrieb:
>>>>>
>>>>>> Thanks for your answer.
>>>>>>
>>>>>> I need the inId because its like ebay: in each productgroup there 
>>>>>> is a collection of "untergruppen/undergroups". And this works: i 
>>>>>> could add objects of produktgruppe and save them (so inId will 
>>>>>> store the reference to the main productgroup).
>>>>>>
>>>>>> The problem is not between productgroup and productgroup (1:n) - 
>>>>>> it is between Productgroup and Product (n:m)
>>>>>>
>>>>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>>>>> core??
>>>>>>
>>>>>> I found also something strange:
>>>>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>>>>> If i start tomcat and then my app - i got the error! If i start my 
>>>>>> app a seconde time everthing works fine ...
>>>>>>
>>>>>> Thanks for help, Thomas
>>>>>>
>>>>>>
>>>>>> Thomas Franke schrieb:
>>>>>>
>>>>>>> Thomas Papke wrote:
>>>>>>>
>>>>>>> Why you need the inId?
>>>>>>>
>>>>>>>
>>>>>>>> Here is my descriptor of the two classes:
>>>>>>>>
>>>>>>>> <class-descriptor
>>>>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>>    table="Produktgruppe"
>>>>>>>>  >
>>>>>>>>    <field-descriptor
>>>>>>>>        name="id"
>>>>>>>>        column="id"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>        primarykey="true"
>>>>>>>>        autoincrement="true"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="inId"
>>>>>>>>        column="inId"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="name"
>>>>>>>>        column="name"
>>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>>    >
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I thing this can't work and I thing also it is a wrong design:
>>>>>>>
>>>>>>>>    </field-descriptor>
>>>>>>>>    <collection-descriptor
>>>>>>>>       name="produktgruppen"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>>       orderby="inId"
>>>>>>>>       sort="DESC"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>       auto-delete="true"
>>>>>>>>    >
>>>>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>>>>    </collection-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>    <collection-descriptor
>>>>>>>>       name="produkt"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>       indirection-table="produkt_produktgruppe"
>>>>>>>>  >
>>>>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>>>>  </collection-descriptor>
>>>>>>>> </class-descriptor>
>>>>>>>>
>>>>>>>
>>>>>>> Take into your Produkt class a collection descriptor with 
>>>>>>> Produktgruppe classes.
>>>>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>>>>> without a collection with Produkt class.
>>>>>>>
>>>>>>>> <class-descriptor
>>>>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>>>>    table="Produkt"
>>>>>>>>  >
>>>>>>>>    <field-descriptor
>>>>>>>>        name="id"
>>>>>>>>        column="id"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>        primarykey="true"
>>>>>>>>        autoincrement="true"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="name"
>>>>>>>>        column="name"
>>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>
>>>>>>>>
>>>>>>>>  <collection-descriptor
>>>>>>>>       name="meinung"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>  >
>>>>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>>>>  </collection-descriptor>
>>>>>>>>   </class-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --------------------------------------------------------------------- 
>>>>>>>
>>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
Ok i have solved the problem.

There was no pk defined for my class called "meinung", because i develop 
step by step and meinung was not yet complet (i found this with some 
more debugging infos in ojb). So in detail there was not problem with my 
n:m association.

So thanks for your help....
But here you see that a better error message should occur - not only 
devide by zero.

Thomas

Armin Waibel schrieb:

>
> Thomas Papke wrote:
>
>> Hi ...
>>
>> yes that could be the problem. For the tables "Produktgruppe" and 
>> "Produkt", i have defined the primary keys in the deskriptor. The 
>> table for decompose the n:m mapping "produkt_produktgruppe" - i have 
>> nothing defined in the descriptor.
>
>
> As you are using a non-decomposed m:n relation the indirection table 
> "produkt_produktgruppe" couldn't be a persistent class, so you 
> shouldn't define a class-descriptor for the indirection table or set 
> the FK fields from product and group as PK fields.
>
> regards,
> Armin
>
>
>> Because as described in the docs of ojb 
>> http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
>> it should work.
>>
>> Did i something wrong?
>> On the bottom of this email again the interessting parts of my 
>> descriptor where you could see that i have defined the pk's for 
>> produktgruppe and produkt in a correct way.
>>
>> Is the possibly a bug of ojb or is something necessary what is not 
>> mentioned in the example for n:m ojb mapping?
>>
>> Thanks, Thomas
>>
>> Armin Waibel schrieb:
>>
>>> Hi Thomas,
>>>
>>> Thomas Papke wrote:
>>>
>>>> The excectly exception (after broker.getCollectionByQuery ...) i 
>>>> got from ojb broker is:
>>>>
>>>> org.apache.ojb.broker.PersistenceBrokerException: 
>>>> java.lang.ArithmeticException: / by zero
>>>>
>>>
>>> In the source the causing line is
>>>
>>> at BasePrefetcher.<init>(BasePrefetcher.java:76)
>>> ...
>>> pkLimit = getPrefetchInLimit() / 
>>> getItemClassDescriptor().getPkFields().length;
>>> ...
>>>
>>> Seems that OJB get a persistent class without defined PK fields. 
>>> Could this be the case?
>>>
>>> regards,
>>> Armin
>>>
>>>
>>>> Thomas Papke schrieb:
>>>>
>>>>> Thanks for your answer.
>>>>>
>>>>> I need the inId because its like ebay: in each productgroup there 
>>>>> is a collection of "untergruppen/undergroups". And this works: i 
>>>>> could add objects of produktgruppe and save them (so inId will 
>>>>> store the reference to the main productgroup).
>>>>>
>>>>> The problem is not between productgroup and productgroup (1:n) - 
>>>>> it is between Productgroup and Product (n:m)
>>>>>
>>>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>>>> core??
>>>>>
>>>>> I found also something strange:
>>>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>>>> If i start tomcat and then my app - i got the error! If i start my 
>>>>> app a seconde time everthing works fine ...
>>>>>
>>>>> Thanks for help, Thomas
>>>>>
>>>>>
>>>>> Thomas Franke schrieb:
>>>>>
>>>>>> Thomas Papke wrote:
>>>>>>
>>>>>> Why you need the inId?
>>>>>>
>>>>>>
>>>>>>> Here is my descriptor of the two classes:
>>>>>>>
>>>>>>> <class-descriptor
>>>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>    table="Produktgruppe"
>>>>>>>  >
>>>>>>>    <field-descriptor
>>>>>>>        name="id"
>>>>>>>        column="id"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>        primarykey="true"
>>>>>>>        autoincrement="true"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="inId"
>>>>>>>        column="inId"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="name"
>>>>>>>        column="name"
>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>    >
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> I thing this can't work and I thing also it is a wrong design:
>>>>>>
>>>>>>>    </field-descriptor>
>>>>>>>    <collection-descriptor
>>>>>>>       name="produktgruppen"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>       orderby="inId"
>>>>>>>       sort="DESC"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>       auto-delete="true"
>>>>>>>    >
>>>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>>>    </collection-descriptor>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>    <collection-descriptor
>>>>>>>       name="produkt"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>       indirection-table="produkt_produktgruppe"
>>>>>>>  >
>>>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>>>  </collection-descriptor>
>>>>>>> </class-descriptor>
>>>>>>>
>>>>>>
>>>>>> Take into your Produkt class a collection descriptor with 
>>>>>> Produktgruppe classes.
>>>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>>>> without a collection with Produkt class.
>>>>>>
>>>>>>> <class-descriptor
>>>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>>>    table="Produkt"
>>>>>>>  >
>>>>>>>    <field-descriptor
>>>>>>>        name="id"
>>>>>>>        column="id"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>        primarykey="true"
>>>>>>>        autoincrement="true"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="name"
>>>>>>>        column="name"
>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>  <collection-descriptor
>>>>>>>       name="meinung"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>  >
>>>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>>>  </collection-descriptor>
>>>>>>>   </class-descriptor>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --------------------------------------------------------------------- 
>>>>>>
>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Armin Waibel <ar...@apache.org>.
Thomas Papke wrote:

> As you say, i have no no class-descriptor for the indirection table! I 
> also very strange why i only get the exception from ojb the first time 
> the application starts in the tomcat env. - the seconde time and so one 
> everthing works fine. After restart of tomcat (and the java vm) - the 
> same again :-/
>

Strange! Could you add some logging statements in BasePrefetcher 
constructor before field 'pkLimit' (which causing the exception). So we 
will see which persistent class cause the isssue.

regards,
Armin


> <class-descriptor
>    class="de.ba.studi.chtp.model.Produktgruppe"
>    table="Produktgruppe"
>  >
>    <field-descriptor
>        name="id"
>        column="id"
>        jdbc-type="INTEGER"
>        primarykey="true"
>        autoincrement="true"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="inId"
>        column="inId"
>        jdbc-type="INTEGER"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="name"
>        column="name"
>        jdbc-type="VARCHAR"
>    >
>    </field-descriptor>
>    <collection-descriptor
>       name="produktgruppen"
>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>       orderby="inId"
>       sort="DESC"
>       auto-retrieve="true"
>       auto-update="true"
>       auto-delete="true"
>    >
>       <inverse-foreignkey field-ref="inId"/>
>    </collection-descriptor>
>    <collection-descriptor
>       name="produkt"
>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>       auto-retrieve="true"
>       auto-update="true"
>       indirection-table="produkt_produktgruppe"
>  >
> *      <fk-pointing-to-this-class column="ProdGruppe_id"/>
>       <fk-pointing-to-element-class column="Prod_Id"/>*
>  </collection-descriptor>
> </class-descriptor>
> 
> <class-descriptor
>    class="de.ba.studi.chtp.model.Produkt"
>    table="Produkt"
>  >
>    <field-descriptor
>        name="id"
>        column="id"
>        jdbc-type="INTEGER"
>        primarykey="true"
>        autoincrement="true"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="name"
>        column="name"
>        jdbc-type="VARCHAR"
>    >
>    </field-descriptor>
> 
> 
>  <collection-descriptor
>       name="meinung"
>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>       auto-retrieve="true"
>       auto-update="true"
>  >
>       <inverse-foreignkey field-ref="prod_id"/>
>  </collection-descriptor>
>   </class-descriptor>
> 
> Thomas
> 
> Armin Waibel schrieb:
> 
>>
>> Thomas Papke wrote:
>>
>>> Hi ...
>>>
>>> yes that could be the problem. For the tables "Produktgruppe" and 
>>> "Produkt", i have defined the primary keys in the deskriptor. The 
>>> table for decompose the n:m mapping "produkt_produktgruppe" - i have 
>>> nothing defined in the descriptor.
>>
>>
>>
>> As you are using a non-decomposed m:n relation the indirection table 
>> "produkt_produktgruppe" couldn't be a persistent class, so you 
>> shouldn't define a class-descriptor for the indirection table or set 
>> the FK fields from product and group as PK fields.
>>
>> regards,
>> Armin
>>
>>
>>> Because as described in the docs of ojb 
>>> http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
>>> it should work.
>>>
>>> Did i something wrong?
>>> On the bottom of this email again the interessting parts of my 
>>> descriptor where you could see that i have defined the pk's for 
>>> produktgruppe and produkt in a correct way.
>>>
>>> Is the possibly a bug of ojb or is something necessary what is not 
>>> mentioned in the example for n:m ojb mapping?
>>>
>>> Thanks, Thomas
>>>
>>> Armin Waibel schrieb:
>>>
>>>> Hi Thomas,
>>>>
>>>> Thomas Papke wrote:
>>>>
>>>>> The excectly exception (after broker.getCollectionByQuery ...) i 
>>>>> got from ojb broker is:
>>>>>
>>>>> org.apache.ojb.broker.PersistenceBrokerException: 
>>>>> java.lang.ArithmeticException: / by zero
>>>>>
>>>>
>>>> In the source the causing line is
>>>>
>>>> at BasePrefetcher.<init>(BasePrefetcher.java:76)
>>>> ...
>>>> pkLimit = getPrefetchInLimit() / 
>>>> getItemClassDescriptor().getPkFields().length;
>>>> ...
>>>>
>>>> Seems that OJB get a persistent class without defined PK fields. 
>>>> Could this be the case?
>>>>
>>>> regards,
>>>> Armin
>>>>
>>>>
>>>>> Thomas Papke schrieb:
>>>>>
>>>>>> Thanks for your answer.
>>>>>>
>>>>>> I need the inId because its like ebay: in each productgroup there 
>>>>>> is a collection of "untergruppen/undergroups". And this works: i 
>>>>>> could add objects of produktgruppe and save them (so inId will 
>>>>>> store the reference to the main productgroup).
>>>>>>
>>>>>> The problem is not between productgroup and productgroup (1:n) - 
>>>>>> it is between Productgroup and Product (n:m)
>>>>>>
>>>>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>>>>> core??
>>>>>>
>>>>>> I found also something strange:
>>>>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>>>>> If i start tomcat and then my app - i got the error! If i start my 
>>>>>> app a seconde time everthing works fine ...
>>>>>>
>>>>>> Thanks for help, Thomas
>>>>>>
>>>>>>
>>>>>> Thomas Franke schrieb:
>>>>>>
>>>>>>> Thomas Papke wrote:
>>>>>>>
>>>>>>> Why you need the inId?
>>>>>>>
>>>>>>>
>>>>>>>> Here is my descriptor of the two classes:
>>>>>>>>
>>>>>>>> <class-descriptor
>>>>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>>    table="Produktgruppe"
>>>>>>>>  >
>>>>>>>>    <field-descriptor
>>>>>>>>        name="id"
>>>>>>>>        column="id"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>        primarykey="true"
>>>>>>>>        autoincrement="true"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="inId"
>>>>>>>>        column="inId"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="name"
>>>>>>>>        column="name"
>>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>>    >
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I thing this can't work and I thing also it is a wrong design:
>>>>>>>
>>>>>>>>    </field-descriptor>
>>>>>>>>    <collection-descriptor
>>>>>>>>       name="produktgruppen"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>>       orderby="inId"
>>>>>>>>       sort="DESC"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>       auto-delete="true"
>>>>>>>>    >
>>>>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>>>>    </collection-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>    <collection-descriptor
>>>>>>>>       name="produkt"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>       indirection-table="produkt_produktgruppe"
>>>>>>>>  >
>>>>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>>>>  </collection-descriptor>
>>>>>>>> </class-descriptor>
>>>>>>>>
>>>>>>>
>>>>>>> Take into your Produkt class a collection descriptor with 
>>>>>>> Produktgruppe classes.
>>>>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>>>>> without a collection with Produkt class.
>>>>>>>
>>>>>>>> <class-descriptor
>>>>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>>>>    table="Produkt"
>>>>>>>>  >
>>>>>>>>    <field-descriptor
>>>>>>>>        name="id"
>>>>>>>>        column="id"
>>>>>>>>        jdbc-type="INTEGER"
>>>>>>>>        primarykey="true"
>>>>>>>>        autoincrement="true"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>    <field-descriptor
>>>>>>>>        name="name"
>>>>>>>>        column="name"
>>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>>    >
>>>>>>>>    </field-descriptor>
>>>>>>>>
>>>>>>>>
>>>>>>>>  <collection-descriptor
>>>>>>>>       name="meinung"
>>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>>>>       auto-retrieve="true"
>>>>>>>>       auto-update="true"
>>>>>>>>  >
>>>>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>>>>  </collection-descriptor>
>>>>>>>>   </class-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --------------------------------------------------------------------- 
>>>>>>>
>>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
As you say, i have no no class-descriptor for the indirection table! I 
also very strange why i only get the exception from ojb the first time 
the application starts in the tomcat env. - the seconde time and so one 
everthing works fine. After restart of tomcat (and the java vm) - the 
same again :-/

<class-descriptor
    class="de.ba.studi.chtp.model.Produktgruppe"
    table="Produktgruppe"
 >
    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
    >
    </field-descriptor>
    <field-descriptor
        name="inId"
        column="inId"
        jdbc-type="INTEGER"
    >
    </field-descriptor>
    <field-descriptor
        name="name"
        column="name"
        jdbc-type="VARCHAR"
    >
    </field-descriptor>
    <collection-descriptor
       name="produktgruppen"
       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
       orderby="inId"
       sort="DESC"
       auto-retrieve="true"
       auto-update="true"
       auto-delete="true"
    >
       <inverse-foreignkey field-ref="inId"/>
    </collection-descriptor>
    <collection-descriptor
       name="produkt"
       element-class-ref="de.ba.studi.chtp.model.Produkt"
       auto-retrieve="true"
       auto-update="true"
       indirection-table="produkt_produktgruppe"
  >
 *      <fk-pointing-to-this-class column="ProdGruppe_id"/>
       <fk-pointing-to-element-class column="Prod_Id"/>*
  </collection-descriptor>
</class-descriptor>

<class-descriptor
    class="de.ba.studi.chtp.model.Produkt"
    table="Produkt"
 >
    <field-descriptor
        name="id"
        column="id"
        jdbc-type="INTEGER"
        primarykey="true"
        autoincrement="true"
    >
    </field-descriptor>
    <field-descriptor
        name="name"
        column="name"
        jdbc-type="VARCHAR"
    >
    </field-descriptor>

 
  <collection-descriptor
       name="meinung"
       element-class-ref="de.ba.studi.chtp.model.Meinung"
       auto-retrieve="true"
       auto-update="true"
  >
       <inverse-foreignkey field-ref="prod_id"/>
  </collection-descriptor>
   
</class-descriptor>

Thomas

Armin Waibel schrieb:

>
> Thomas Papke wrote:
>
>> Hi ...
>>
>> yes that could be the problem. For the tables "Produktgruppe" and 
>> "Produkt", i have defined the primary keys in the deskriptor. The 
>> table for decompose the n:m mapping "produkt_produktgruppe" - i have 
>> nothing defined in the descriptor.
>
>
> As you are using a non-decomposed m:n relation the indirection table 
> "produkt_produktgruppe" couldn't be a persistent class, so you 
> shouldn't define a class-descriptor for the indirection table or set 
> the FK fields from product and group as PK fields.
>
> regards,
> Armin
>
>
>> Because as described in the docs of ojb 
>> http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
>> it should work.
>>
>> Did i something wrong?
>> On the bottom of this email again the interessting parts of my 
>> descriptor where you could see that i have defined the pk's for 
>> produktgruppe and produkt in a correct way.
>>
>> Is the possibly a bug of ojb or is something necessary what is not 
>> mentioned in the example for n:m ojb mapping?
>>
>> Thanks, Thomas
>>
>> Armin Waibel schrieb:
>>
>>> Hi Thomas,
>>>
>>> Thomas Papke wrote:
>>>
>>>> The excectly exception (after broker.getCollectionByQuery ...) i 
>>>> got from ojb broker is:
>>>>
>>>> org.apache.ojb.broker.PersistenceBrokerException: 
>>>> java.lang.ArithmeticException: / by zero
>>>>
>>>
>>> In the source the causing line is
>>>
>>> at BasePrefetcher.<init>(BasePrefetcher.java:76)
>>> ...
>>> pkLimit = getPrefetchInLimit() / 
>>> getItemClassDescriptor().getPkFields().length;
>>> ...
>>>
>>> Seems that OJB get a persistent class without defined PK fields. 
>>> Could this be the case?
>>>
>>> regards,
>>> Armin
>>>
>>>
>>>> Thomas Papke schrieb:
>>>>
>>>>> Thanks for your answer.
>>>>>
>>>>> I need the inId because its like ebay: in each productgroup there 
>>>>> is a collection of "untergruppen/undergroups". And this works: i 
>>>>> could add objects of produktgruppe and save them (so inId will 
>>>>> store the reference to the main productgroup).
>>>>>
>>>>> The problem is not between productgroup and productgroup (1:n) - 
>>>>> it is between Productgroup and Product (n:m)
>>>>>
>>>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>>>> core??
>>>>>
>>>>> I found also something strange:
>>>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>>>> If i start tomcat and then my app - i got the error! If i start my 
>>>>> app a seconde time everthing works fine ...
>>>>>
>>>>> Thanks for help, Thomas
>>>>>
>>>>>
>>>>> Thomas Franke schrieb:
>>>>>
>>>>>> Thomas Papke wrote:
>>>>>>
>>>>>> Why you need the inId?
>>>>>>
>>>>>>
>>>>>>> Here is my descriptor of the two classes:
>>>>>>>
>>>>>>> <class-descriptor
>>>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>    table="Produktgruppe"
>>>>>>>  >
>>>>>>>    <field-descriptor
>>>>>>>        name="id"
>>>>>>>        column="id"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>        primarykey="true"
>>>>>>>        autoincrement="true"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="inId"
>>>>>>>        column="inId"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="name"
>>>>>>>        column="name"
>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>    >
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> I thing this can't work and I thing also it is a wrong design:
>>>>>>
>>>>>>>    </field-descriptor>
>>>>>>>    <collection-descriptor
>>>>>>>       name="produktgruppen"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>>       orderby="inId"
>>>>>>>       sort="DESC"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>       auto-delete="true"
>>>>>>>    >
>>>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>>>    </collection-descriptor>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>    <collection-descriptor
>>>>>>>       name="produkt"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>       indirection-table="produkt_produktgruppe"
>>>>>>>  >
>>>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>>>  </collection-descriptor>
>>>>>>> </class-descriptor>
>>>>>>>
>>>>>>
>>>>>> Take into your Produkt class a collection descriptor with 
>>>>>> Produktgruppe classes.
>>>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>>>> without a collection with Produkt class.
>>>>>>
>>>>>>> <class-descriptor
>>>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>>>    table="Produkt"
>>>>>>>  >
>>>>>>>    <field-descriptor
>>>>>>>        name="id"
>>>>>>>        column="id"
>>>>>>>        jdbc-type="INTEGER"
>>>>>>>        primarykey="true"
>>>>>>>        autoincrement="true"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>    <field-descriptor
>>>>>>>        name="name"
>>>>>>>        column="name"
>>>>>>>        jdbc-type="VARCHAR"
>>>>>>>    >
>>>>>>>    </field-descriptor>
>>>>>>>
>>>>>>>
>>>>>>>  <collection-descriptor
>>>>>>>       name="meinung"
>>>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>>>       auto-retrieve="true"
>>>>>>>       auto-update="true"
>>>>>>>  >
>>>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>>>  </collection-descriptor>
>>>>>>>   </class-descriptor>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --------------------------------------------------------------------- 
>>>>>>
>>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Armin Waibel <ar...@apache.org>.
Thomas Papke wrote:

> Hi ...
> 
> yes that could be the problem. For the tables "Produktgruppe" and 
> "Produkt", i have defined the primary keys in the deskriptor. The table 
> for decompose the n:m mapping "produkt_produktgruppe" - i have nothing 
> defined in the descriptor.

As you are using a non-decomposed m:n relation the indirection table 
"produkt_produktgruppe" couldn't be a persistent class, so you shouldn't 
define a class-descriptor for the indirection table or set the FK fields 
from product and group as PK fields.

regards,
Armin


> Because as described in the docs of ojb 
> http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
> it should work.
> 
> Did i something wrong?
> On the bottom of this email again the interessting parts of my 
> descriptor where you could see that i have defined the pk's for 
> produktgruppe and produkt in a correct way.
> 
> Is the possibly a bug of ojb or is something necessary what is not 
> mentioned in the example for n:m ojb mapping?
> 
> Thanks, Thomas
> 
> Armin Waibel schrieb:
> 
>> Hi Thomas,
>>
>> Thomas Papke wrote:
>>
>>> The excectly exception (after broker.getCollectionByQuery ...) i got 
>>> from ojb broker is:
>>>
>>> org.apache.ojb.broker.PersistenceBrokerException: 
>>> java.lang.ArithmeticException: / by zero
>>>
>>
>> In the source the causing line is
>>
>> at BasePrefetcher.<init>(BasePrefetcher.java:76)
>> ...
>> pkLimit = getPrefetchInLimit() / 
>> getItemClassDescriptor().getPkFields().length;
>> ...
>>
>> Seems that OJB get a persistent class without defined PK fields. Could 
>> this be the case?
>>
>> regards,
>> Armin
>>
>>
>>> Thomas Papke schrieb:
>>>
>>>> Thanks for your answer.
>>>>
>>>> I need the inId because its like ebay: in each productgroup there is 
>>>> a collection of "untergruppen/undergroups". And this works: i could 
>>>> add objects of produktgruppe and save them (so inId will store the 
>>>> reference to the main productgroup).
>>>>
>>>> The problem is not between productgroup and productgroup (1:n) - it 
>>>> is between Productgroup and Product (n:m)
>>>>
>>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>>> core??
>>>>
>>>> I found also something strange:
>>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>>> If i start tomcat and then my app - i got the error! If i start my 
>>>> app a seconde time everthing works fine ...
>>>>
>>>> Thanks for help, Thomas
>>>>
>>>>
>>>> Thomas Franke schrieb:
>>>>
>>>>> Thomas Papke wrote:
>>>>>
>>>>> Why you need the inId?
>>>>>
>>>>>
>>>>>> Here is my descriptor of the two classes:
>>>>>>
>>>>>> <class-descriptor
>>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>    table="Produktgruppe"
>>>>>>  >
>>>>>>    <field-descriptor
>>>>>>        name="id"
>>>>>>        column="id"
>>>>>>        jdbc-type="INTEGER"
>>>>>>        primarykey="true"
>>>>>>        autoincrement="true"
>>>>>>    >
>>>>>>    </field-descriptor>
>>>>>>    <field-descriptor
>>>>>>        name="inId"
>>>>>>        column="inId"
>>>>>>        jdbc-type="INTEGER"
>>>>>>    >
>>>>>>    </field-descriptor>
>>>>>>    <field-descriptor
>>>>>>        name="name"
>>>>>>        column="name"
>>>>>>        jdbc-type="VARCHAR"
>>>>>>    >
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> I thing this can't work and I thing also it is a wrong design:
>>>>>
>>>>>>    </field-descriptor>
>>>>>>    <collection-descriptor
>>>>>>       name="produktgruppen"
>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>>       orderby="inId"
>>>>>>       sort="DESC"
>>>>>>       auto-retrieve="true"
>>>>>>       auto-update="true"
>>>>>>       auto-delete="true"
>>>>>>    >
>>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>>    </collection-descriptor>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>    <collection-descriptor
>>>>>>       name="produkt"
>>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>>       auto-retrieve="true"
>>>>>>       auto-update="true"
>>>>>>       indirection-table="produkt_produktgruppe"
>>>>>>  >
>>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>>  </collection-descriptor>
>>>>>> </class-descriptor>
>>>>>>
>>>>>
>>>>> Take into your Produkt class a collection descriptor with 
>>>>> Produktgruppe classes.
>>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>>> without a collection with Produkt class.
>>>>>
>>>>>> <class-descriptor
>>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>>    table="Produkt"
>>>>>>  >
>>>>>>    <field-descriptor
>>>>>>        name="id"
>>>>>>        column="id"
>>>>>>        jdbc-type="INTEGER"
>>>>>>        primarykey="true"
>>>>>>        autoincrement="true"
>>>>>>    >
>>>>>>    </field-descriptor>
>>>>>>    <field-descriptor
>>>>>>        name="name"
>>>>>>        column="name"
>>>>>>        jdbc-type="VARCHAR"
>>>>>>    >
>>>>>>    </field-descriptor>
>>>>>>
>>>>>>
>>>>>>  <collection-descriptor
>>>>>>       name="meinung"
>>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>>       auto-retrieve="true"
>>>>>>       auto-update="true"
>>>>>>  >
>>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>>  </collection-descriptor>
>>>>>>   </class-descriptor>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
Hi ...

yes that could be the problem. For the tables "Produktgruppe" and 
"Produkt", i have defined the primary keys in the deskriptor. The table 
for decompose the n:m mapping "produkt_produktgruppe" - i have nothing 
defined in the descriptor. Because as described in the docs of ojb 
http://db.apache.org/ojb/docu/guides/basic-technique.html#Support+for+Non-Decomposed+m%3An+Mappings 
it should work.

Did i something wrong?
On the bottom of this email again the interessting parts of my 
descriptor where you could see that i have defined the pk's for 
produktgruppe and produkt in a correct way.

Is the possibly a bug of ojb or is something necessary what is not 
mentioned in the example for n:m ojb mapping?

Thanks, Thomas

Armin Waibel schrieb:

> Hi Thomas,
>
> Thomas Papke wrote:
>
>> The excectly exception (after broker.getCollectionByQuery ...) i got 
>> from ojb broker is:
>>
>> org.apache.ojb.broker.PersistenceBrokerException: 
>> java.lang.ArithmeticException: / by zero
>>
>
> In the source the causing line is
>
> at BasePrefetcher.<init>(BasePrefetcher.java:76)
> ...
> pkLimit = getPrefetchInLimit() / 
> getItemClassDescriptor().getPkFields().length;
> ...
>
> Seems that OJB get a persistent class without defined PK fields. Could 
> this be the case?
>
> regards,
> Armin
>
>
>> Thomas Papke schrieb:
>>
>>> Thanks for your answer.
>>>
>>> I need the inId because its like ebay: in each productgroup there is 
>>> a collection of "untergruppen/undergroups". And this works: i could 
>>> add objects of produktgruppe and save them (so inId will store the 
>>> reference to the main productgroup).
>>>
>>> The problem is not between productgroup and productgroup (1:n) - it 
>>> is between Productgroup and Product (n:m)
>>>
>>> And why did i got a arithmetic exception (/ by zero) from the ojb 
>>> core??
>>>
>>> I found also something strange:
>>> The OJB Framwork and my Application runs in a Tomcat environment.
>>> If i start tomcat and then my app - i got the error! If i start my 
>>> app a seconde time everthing works fine ...
>>>
>>> Thanks for help, Thomas
>>>
>>>
>>> Thomas Franke schrieb:
>>>
>>>> Thomas Papke wrote:
>>>>
>>>> Why you need the inId?
>>>>
>>>>
>>>>> Here is my descriptor of the two classes:
>>>>>
>>>>> <class-descriptor
>>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>>    table="Produktgruppe"
>>>>>  >
>>>>>    <field-descriptor
>>>>>        name="id"
>>>>>        column="id"
>>>>>        jdbc-type="INTEGER"
>>>>>        primarykey="true"
>>>>>        autoincrement="true"
>>>>>    >
>>>>>    </field-descriptor>
>>>>>    <field-descriptor
>>>>>        name="inId"
>>>>>        column="inId"
>>>>>        jdbc-type="INTEGER"
>>>>>    >
>>>>>    </field-descriptor>
>>>>>    <field-descriptor
>>>>>        name="name"
>>>>>        column="name"
>>>>>        jdbc-type="VARCHAR"
>>>>>    >
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> I thing this can't work and I thing also it is a wrong design:
>>>>
>>>>>    </field-descriptor>
>>>>>    <collection-descriptor
>>>>>       name="produktgruppen"
>>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>>       orderby="inId"
>>>>>       sort="DESC"
>>>>>       auto-retrieve="true"
>>>>>       auto-update="true"
>>>>>       auto-delete="true"
>>>>>    >
>>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>>    </collection-descriptor>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>    <collection-descriptor
>>>>>       name="produkt"
>>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>>       auto-retrieve="true"
>>>>>       auto-update="true"
>>>>>       indirection-table="produkt_produktgruppe"
>>>>>  >
>>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>>  </collection-descriptor>
>>>>> </class-descriptor>
>>>>>
>>>>
>>>> Take into your Produkt class a collection descriptor with 
>>>> Produktgruppe classes.
>>>> For that case I would write a spezial mapping for Produktgruppe 
>>>> without a collection with Produkt class.
>>>>
>>>>> <class-descriptor
>>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>>    table="Produkt"
>>>>>  >
>>>>>    <field-descriptor
>>>>>        name="id"
>>>>>        column="id"
>>>>>        jdbc-type="INTEGER"
>>>>>        primarykey="true"
>>>>>        autoincrement="true"
>>>>>    >
>>>>>    </field-descriptor>
>>>>>    <field-descriptor
>>>>>        name="name"
>>>>>        column="name"
>>>>>        jdbc-type="VARCHAR"
>>>>>    >
>>>>>    </field-descriptor>
>>>>>
>>>>>
>>>>>  <collection-descriptor
>>>>>       name="meinung"
>>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>>       auto-retrieve="true"
>>>>>       auto-update="true"
>>>>>  >
>>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>>  </collection-descriptor>
>>>>>   </class-descriptor>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Armin Waibel <ar...@apache.org>.
Hi Thomas,

Thomas Papke wrote:
> The excectly exception (after broker.getCollectionByQuery ...) i got 
> from ojb broker is:
> 
> org.apache.ojb.broker.PersistenceBrokerException: 
> java.lang.ArithmeticException: / by zero
> 

In the source the causing line is

at BasePrefetcher.<init>(BasePrefetcher.java:76)
...
pkLimit = getPrefetchInLimit() / 
getItemClassDescriptor().getPkFields().length;
...

Seems that OJB get a persistent class without defined PK fields. Could 
this be the case?

regards,
Armin


> Thomas Papke schrieb:
> 
>> Thanks for your answer.
>>
>> I need the inId because its like ebay: in each productgroup there is a 
>> collection of "untergruppen/undergroups". And this works: i could add 
>> objects of produktgruppe and save them (so inId will store the 
>> reference to the main productgroup).
>>
>> The problem is not between productgroup and productgroup (1:n) - it is 
>> between Productgroup and Product (n:m)
>>
>> And why did i got a arithmetic exception (/ by zero) from the ojb core??
>>
>> I found also something strange:
>> The OJB Framwork and my Application runs in a Tomcat environment.
>> If i start tomcat and then my app - i got the error! If i start my app 
>> a seconde time everthing works fine ...
>>
>> Thanks for help, Thomas
>>
>>
>> Thomas Franke schrieb:
>>
>>> Thomas Papke wrote:
>>>
>>> Why you need the inId?
>>>
>>>
>>>> Here is my descriptor of the two classes:
>>>>
>>>> <class-descriptor
>>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>>    table="Produktgruppe"
>>>>  >
>>>>    <field-descriptor
>>>>        name="id"
>>>>        column="id"
>>>>        jdbc-type="INTEGER"
>>>>        primarykey="true"
>>>>        autoincrement="true"
>>>>    >
>>>>    </field-descriptor>
>>>>    <field-descriptor
>>>>        name="inId"
>>>>        column="inId"
>>>>        jdbc-type="INTEGER"
>>>>    >
>>>>    </field-descriptor>
>>>>    <field-descriptor
>>>>        name="name"
>>>>        column="name"
>>>>        jdbc-type="VARCHAR"
>>>>    >
>>>
>>>
>>>
>>>
>>> I thing this can't work and I thing also it is a wrong design:
>>>
>>>>    </field-descriptor>
>>>>    <collection-descriptor
>>>>       name="produktgruppen"
>>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>>       orderby="inId"
>>>>       sort="DESC"
>>>>       auto-retrieve="true"
>>>>       auto-update="true"
>>>>       auto-delete="true"
>>>>    >
>>>>       <inverse-foreignkey field-ref="inId"/>
>>>>    </collection-descriptor>
>>>
>>>
>>>
>>>
>>>
>>>>    <collection-descriptor
>>>>       name="produkt"
>>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>>       auto-retrieve="true"
>>>>       auto-update="true"
>>>>       indirection-table="produkt_produktgruppe"
>>>>  >
>>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>>  </collection-descriptor>
>>>> </class-descriptor>
>>>>
>>>
>>> Take into your Produkt class a collection descriptor with 
>>> Produktgruppe classes.
>>> For that case I would write a spezial mapping for Produktgruppe 
>>> without a collection with Produkt class.
>>>
>>>> <class-descriptor
>>>>    class="de.ba.studi.chtp.model.Produkt"
>>>>    table="Produkt"
>>>>  >
>>>>    <field-descriptor
>>>>        name="id"
>>>>        column="id"
>>>>        jdbc-type="INTEGER"
>>>>        primarykey="true"
>>>>        autoincrement="true"
>>>>    >
>>>>    </field-descriptor>
>>>>    <field-descriptor
>>>>        name="name"
>>>>        column="name"
>>>>        jdbc-type="VARCHAR"
>>>>    >
>>>>    </field-descriptor>
>>>>
>>>>
>>>>  <collection-descriptor
>>>>       name="meinung"
>>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>>       auto-retrieve="true"
>>>>       auto-update="true"
>>>>  >
>>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>>  </collection-descriptor>
>>>>   </class-descriptor>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
The excectly exception (after broker.getCollectionByQuery ...) i got 
from ojb broker is:

org.apache.ojb.broker.PersistenceBrokerException: 
java.lang.ArithmeticException: / by zero

Thomas Papke schrieb:

> Thanks for your answer.
>
> I need the inId because its like ebay: in each productgroup there is a 
> collection of "untergruppen/undergroups". And this works: i could add 
> objects of produktgruppe and save them (so inId will store the 
> reference to the main productgroup).
>
> The problem is not between productgroup and productgroup (1:n) - it is 
> between Productgroup and Product (n:m)
>
> And why did i got a arithmetic exception (/ by zero) from the ojb core??
>
> I found also something strange:
> The OJB Framwork and my Application runs in a Tomcat environment.
> If i start tomcat and then my app - i got the error! If i start my app 
> a seconde time everthing works fine ...
>
> Thanks for help, Thomas
>
>
> Thomas Franke schrieb:
>
>> Thomas Papke wrote:
>>
>> Why you need the inId?
>>
>>
>>> Here is my descriptor of the two classes:
>>>
>>> <class-descriptor
>>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>>    table="Produktgruppe"
>>>  >
>>>    <field-descriptor
>>>        name="id"
>>>        column="id"
>>>        jdbc-type="INTEGER"
>>>        primarykey="true"
>>>        autoincrement="true"
>>>    >
>>>    </field-descriptor>
>>>    <field-descriptor
>>>        name="inId"
>>>        column="inId"
>>>        jdbc-type="INTEGER"
>>>    >
>>>    </field-descriptor>
>>>    <field-descriptor
>>>        name="name"
>>>        column="name"
>>>        jdbc-type="VARCHAR"
>>>    >
>>
>>
>>
>> I thing this can't work and I thing also it is a wrong design:
>>
>>>    </field-descriptor>
>>>    <collection-descriptor
>>>       name="produktgruppen"
>>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>>       orderby="inId"
>>>       sort="DESC"
>>>       auto-retrieve="true"
>>>       auto-update="true"
>>>       auto-delete="true"
>>>    >
>>>       <inverse-foreignkey field-ref="inId"/>
>>>    </collection-descriptor>
>>
>>
>>
>>
>>>    <collection-descriptor
>>>       name="produkt"
>>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>>       auto-retrieve="true"
>>>       auto-update="true"
>>>       indirection-table="produkt_produktgruppe"
>>>  >
>>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>>  </collection-descriptor>
>>> </class-descriptor>
>>>
>>
>> Take into your Produkt class a collection descriptor with 
>> Produktgruppe classes.
>> For that case I would write a spezial mapping for Produktgruppe 
>> without a collection with Produkt class.
>>
>>> <class-descriptor
>>>    class="de.ba.studi.chtp.model.Produkt"
>>>    table="Produkt"
>>>  >
>>>    <field-descriptor
>>>        name="id"
>>>        column="id"
>>>        jdbc-type="INTEGER"
>>>        primarykey="true"
>>>        autoincrement="true"
>>>    >
>>>    </field-descriptor>
>>>    <field-descriptor
>>>        name="name"
>>>        column="name"
>>>        jdbc-type="VARCHAR"
>>>    >
>>>    </field-descriptor>
>>>
>>>
>>>  <collection-descriptor
>>>       name="meinung"
>>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>>       auto-retrieve="true"
>>>       auto-update="true"
>>>  >
>>>       <inverse-foreignkey field-ref="prod_id"/>
>>>  </collection-descriptor>
>>>   </class-descriptor>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Franke <fr...@softenergy.de>.
Thomas Papke wrote:

> Did you use a Non-Decomposed mapping or manual-decomposing mapping with 
> a object as relation 
We use non-decomposed mappings and haven't any mappings for the 
intersection tables.
Do you have one or more mappings for your tables?
Sometimes there are problems, when there are differences between the 
mappings for the same table.

Here is one example:

<class-descriptor
class="de.mhr.wis.DBAdapter.rawdata.masterdata.AdressIdAndName"
table="adressen"
 >
  <field-descriptor id="1"
   name="adressen_id"
   column="adressen_id"
   jdbc-type="INTEGER"
   primarykey="true"
   autoincrement="true"
   access="readonly"
   sequence-name="ADRESSEN_ID_SEQ"
   />
   <field-descriptor id="2"
    name="name"
    column="name"
    jdbc-type="VARCHAR"
    nullable="true"
    />

  <collection-descriptor
   name="adressarten"
   collection-class=
     "org.apache.ojb.broker.util.
      collections.ManageableArrayList"
   element-class-ref=
     "de.mhr.wis.DBAdapter
     .ojbAdapter.administration.OjbAdressart"
   auto-retrieve="false"
   auto-update="false"
   indirection-table="adressen_adressart"
   >
   <fk-pointing-to-this-class column="adressen_id"/>
   <fk-pointing-to-element-class column="adressart_id"/>
  </collection-descriptor>
</class-descriptor>


<class-descriptor
		class="de.mhr.wis.DBAdapter.ojbAdapter.administration.OjbAdressart"
		table="adressart"
	>
		<field-descriptor
			name="adressartId"
			column="adressart_id"
			jdbc-type="INTEGER"
			primarykey="true"
			autoincrement="true"
			access="readonly"
			sequence-name="ADRESSART_ID_SEQ"
		/>
		<field-descriptor
			name="adressartName"
			column="adressart_name"
			jdbc-type="VARCHAR"
			nullable="true"
		/>
		<field-descriptor
			name="adresstypName"
			column="adresstyp_name"
			jdbc-type="VARCHAR"
			nullable="true"
		/>
		<field-descriptor
			name="adressart"
			column="adressart"
			jdbc-type="INTEGER"
			nullable="true"
		/>
		<field-descriptor
			name="adresstyp"
			column="adresstyp"
			jdbc-type="INTEGER"
			nullable="true"
		/>
		
	</class-descriptor>

regards

Thomas





---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
Did you use a Non-Decomposed mapping or manual-decomposing mapping with 
a object as relation 
(http://db.apache.org/ojb/docu/guides/basic-technique.html#Mapping+m%3An+associations)?

I think OJB has a problem with the non-decomposed mapping??? Could you 
send me the part of your descriptor where your application use n:m mapping?


Thanks, Thomas

Thomas Franke schrieb:

> Thomas Papke wrote:
>
>> I need the inId because its like ebay: in each productgroup there is 
>> a collection of "untergruppen/undergroups". And this works: i could 
>> add objects of produktgruppe and save them (so inId will store the 
>> reference to the main productgroup).
>
> I tought first on a problem that we had. Sorry, I was wrong. :)
>
>> The problem is not between productgroup and productgroup (1:n) - it 
>> is between Productgroup and Product (n:m)
>
> We have in our application similar relationships and our mappings look 
> like your mapping and it's working.
>
> regards
>
> Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Franke <fr...@softenergy.de>.
Thomas Papke wrote:

> I need the inId because its like ebay: in each productgroup there is a 
> collection of "untergruppen/undergroups". And this works: i could add 
> objects of produktgruppe and save them (so inId will store the reference 
> to the main productgroup).
I tought first on a problem that we had. Sorry, I was wrong. :)

> The problem is not between productgroup and productgroup (1:n) - it is 
> between Productgroup and Product (n:m)
We have in our application similar relationships and our mappings look 
like your mapping and it's working.

regards

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Papke <we...@thopap.de>.
Thanks for your answer.

I need the inId because its like ebay: in each productgroup there is a 
collection of "untergruppen/undergroups". And this works: i could add 
objects of produktgruppe and save them (so inId will store the reference 
to the main productgroup).

The problem is not between productgroup and productgroup (1:n) - it is 
between Productgroup and Product (n:m)

And why did i got a arithmetic exception (/ by zero) from the ojb core??

I found also something strange:
The OJB Framwork and my Application runs in a Tomcat environment.
If i start tomcat and then my app - i got the error! If i start my app a 
seconde time everthing works fine ...

Thanks for help, Thomas


Thomas Franke schrieb:

> Thomas Papke wrote:
>
> Why you need the inId?
>
>
>> Here is my descriptor of the two classes:
>>
>> <class-descriptor
>>    class="de.ba.studi.chtp.model.Produktgruppe"
>>    table="Produktgruppe"
>>  >
>>    <field-descriptor
>>        name="id"
>>        column="id"
>>        jdbc-type="INTEGER"
>>        primarykey="true"
>>        autoincrement="true"
>>    >
>>    </field-descriptor>
>>    <field-descriptor
>>        name="inId"
>>        column="inId"
>>        jdbc-type="INTEGER"
>>    >
>>    </field-descriptor>
>>    <field-descriptor
>>        name="name"
>>        column="name"
>>        jdbc-type="VARCHAR"
>>    >
>
>
> I thing this can't work and I thing also it is a wrong design:
>
>>    </field-descriptor>
>>    <collection-descriptor
>>       name="produktgruppen"
>>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>>       orderby="inId"
>>       sort="DESC"
>>       auto-retrieve="true"
>>       auto-update="true"
>>       auto-delete="true"
>>    >
>>       <inverse-foreignkey field-ref="inId"/>
>>    </collection-descriptor>
>
>
>
>>    <collection-descriptor
>>       name="produkt"
>>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>>       auto-retrieve="true"
>>       auto-update="true"
>>       indirection-table="produkt_produktgruppe"
>>  >
>>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>>       <fk-pointing-to-element-class column="Prod_Id"/>
>>  </collection-descriptor>
>> </class-descriptor>
>>
>
> Take into your Produkt class a collection descriptor with 
> Produktgruppe classes.
> For that case I would write a spezial mapping for Produktgruppe 
> without a collection with Produkt class.
>
>> <class-descriptor
>>    class="de.ba.studi.chtp.model.Produkt"
>>    table="Produkt"
>>  >
>>    <field-descriptor
>>        name="id"
>>        column="id"
>>        jdbc-type="INTEGER"
>>        primarykey="true"
>>        autoincrement="true"
>>    >
>>    </field-descriptor>
>>    <field-descriptor
>>        name="name"
>>        column="name"
>>        jdbc-type="VARCHAR"
>>    >
>>    </field-descriptor>
>>
>>
>>  <collection-descriptor
>>       name="meinung"
>>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>>       auto-retrieve="true"
>>       auto-update="true"
>>  >
>>       <inverse-foreignkey field-ref="prod_id"/>
>>  </collection-descriptor>
>>   </class-descriptor>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with n:m association

Posted by Thomas Franke <fr...@softenergy.de>.
Thomas Papke wrote:

Why you need the inId?


> Here is my descriptor of the two classes:
> 
> <class-descriptor
>    class="de.ba.studi.chtp.model.Produktgruppe"
>    table="Produktgruppe"
>  >
>    <field-descriptor
>        name="id"
>        column="id"
>        jdbc-type="INTEGER"
>        primarykey="true"
>        autoincrement="true"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="inId"
>        column="inId"
>        jdbc-type="INTEGER"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="name"
>        column="name"
>        jdbc-type="VARCHAR"
>    >

I thing this can't work and I thing also it is a wrong design:

>    </field-descriptor>
>    <collection-descriptor
>       name="produktgruppen"
>       element-class-ref="de.ba.studi.chtp.model.Produktgruppe"
>       orderby="inId"
>       sort="DESC"
>       auto-retrieve="true"
>       auto-update="true"
>       auto-delete="true"
>    >
>       <inverse-foreignkey field-ref="inId"/>
>    </collection-descriptor>


>    <collection-descriptor
>       name="produkt"
>       element-class-ref="de.ba.studi.chtp.model.Produkt"
>       auto-retrieve="true"
>       auto-update="true"
>       indirection-table="produkt_produktgruppe"
>  >
>       <fk-pointing-to-this-class column="ProdGruppe_id"/>
>       <fk-pointing-to-element-class column="Prod_Id"/>
>  </collection-descriptor>
> </class-descriptor>
> 

Take into your Produkt class a collection descriptor with Produktgruppe 
classes.
For that case I would write a spezial mapping for Produktgruppe without 
a collection with Produkt class.

> <class-descriptor
>    class="de.ba.studi.chtp.model.Produkt"
>    table="Produkt"
>  >
>    <field-descriptor
>        name="id"
>        column="id"
>        jdbc-type="INTEGER"
>        primarykey="true"
>        autoincrement="true"
>    >
>    </field-descriptor>
>    <field-descriptor
>        name="name"
>        column="name"
>        jdbc-type="VARCHAR"
>    >
>    </field-descriptor>
> 
> 
>  <collection-descriptor
>       name="meinung"
>       element-class-ref="de.ba.studi.chtp.model.Meinung"
>       auto-retrieve="true"
>       auto-update="true"
>  >
>       <inverse-foreignkey field-ref="prod_id"/>
>  </collection-descriptor>
>   </class-descriptor>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org