please add more of the stack trace
jakob
Claudio Romano wrote:
i have a problem to update and/or save my class to the database. The repository and the class seems to be ok. But everytime i save or update
my Class i become the following error:
"Cannot convert class java.lang.Integer to SQL type requested due to java.lang.ArrayIndexOutOfBoundsException - 2"
can someone tell me when or why this happens?? or what im
doing wrong?
Hi
I use ojb 0.9.9, mySQL database, jdk 1.4.1_01 on win 2000.
My Class Members are:
[java]
public class Products {
protected int id;
protected int quantity;
protected String model;
protected String image;
protected double price;
protected Date dateAdded;
protected Date lastModified;
protected Date dateAvailable;
protected double weight;
protected int status;
protected int taxClassId;
protected int manufacturersId;
protected int productsOrdered;
protected Manufacturers manufacturers;
protected ProductsSpecials productsSpecials;
protected Collection productsDescription;
protected Collection categoriesDesc;
[/java]
[repository]
<class-descriptor class="Products" table="products">
<field-descriptor id="1" name="id" column="products_id"
jdbc-type="INTEGER" autoincrement="true"
primarykey="true" nullable="false" length="11"/>
<field-descriptor id="2" name="quantity" column="products_quantity" jdbc-type="INTEGER" nullable="false" length="4"/>
<field-descriptor id="3" name="model" column="products_model" jdbc-type="VARCHAR" length="12"/>
<field-descriptor id="4" name="image" column="products_image" jdbc-type="VARCHAR" length="64"/>
<field-descriptor id="5" name="price" column="products_price"
jdbc-type="DOUBLE" nullable="false" lenght="15" precision="4"/>
<field-descriptor id="6" name="dateAdded" column="products_date_added" jdbc-type="DATE" nullable="false" indexed="true"/>
<field-descriptor id="7" name="lastModified"
column="products_last_modified" jdbc-type="DATE"/>
<field-descriptor id="8" name="dateAvailable" column="products_date_available" jdbc-type="DATE"/>
<field-descriptor id="9" name="weight" column="products_weight" jdbc-type="DOUBLE" nullable="false" lenght="5" precision="2"/>
<field-descriptor id="10" name="status" column="products_status"
jdbc-type="INTEGER" nullable="false" length="11"/>
<field-descriptor id="11" name="taxClassId" column="products_tax_class_id" jdbc-type="INTEGER" nullable="false" length="11"/>
<field-descriptor id="12" name="manufacturersId" column="manufacturers_id" jdbc-type="INTEGER" length="11"/>
<field-descriptor id="13" name="productsOrdered"
column="products_ordered" jdbc-type="INTEGER" length="11"/>
<collection-descriptor element-class-ref="CategoriesDescription" name="categoriesDesc"
indirection-table="products_to_categories" auto-delete="false" auto-update="false" auto-retrieve="true" >
<fk-pointing-to-this-class
column="products_id"/>
<fk-pointing-to-element-class
column="categories_id"/>
</collection-descriptor>
<reference-descriptor name="manufacturers" class-ref="Manufacturers"> <foreignkey field-id-ref="12"/> </reference-descriptor>
<reference-descriptor name="productsSpecials" class-ref="ProductsSpecials"> <foreignkey field-id-ref="1"/> </reference-descriptor>
<collection-descriptor element-class-ref="ProductsDescription"
name="productsDescription" auto-delete="true" auto-update="true" auto-retrieve="true">
<inverse-foreignkey field-id-ref="1"/> </collection-descriptor> </class-descriptor>
[/repository]
My Class ( Products) seems to filled up correctly in my Application. Then i store the Object like this:
[java] br = PersistenceBrokerFactory.defaultPersistenceBroker(); br.beginTransaction(); br.store( toSaveObject); br.commitTransaction(); [/java]
after that i become this exception:
[EXCEPTION]
java.sql.SQLException: Cannot convert class java.lang.Integer to SQL
type requested due to java.lang.ArrayIndexOutOfBoundsException - 2
at
com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:861)
at
com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:881)
at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectForStatemen
t(Unknown Source)
[/EXCEPTION]
-----Original Message-----
From: Jakob Braeuchi [mailto:[EMAIL PROTECTED] Sent: Friday, March 21, 2003 5:28 PM
To: OJB Users List
Subject: Re: Update and Save Problem
hi claudio,
a little bit more information could be useful.
jakob
Claudio Romano wrote:
--------------------------------------------------------------------- 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]