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: [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]
--------------------------------------------------------------------- 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]
