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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



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



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




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



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



Reply via email to