Castor (as far as I know) doesnt do any serialization on arrays or
anything for that matter. My guess is that it actually just sticks the
results of the toString or String.valueOf into the field in the
database. This means it will store the first time, but it will not be
able to load it at all. So even if you do insert it, it wont be any
good because you wont be able to load it.

Again, as stated above, castor does not support arrays of any type in
a database field yet. Thats not saying it never will, but for now its
simply not going to work, period.

As far as using the second table, there would only be 2 columns, and
it would be a 1:m relationship. You could set it up like the
following:
create table myArrays(id int, parentId int, contents varchar(50));

With a mapping something like:

<class name="my.parent" id="id" ....>
...
 <field name="myArray" type="string" collection="arrary">
   <sql many-key="parentId"/>
</field>
..
</class>

<class name="my.array" id="id" ....>
...
 <field name="myParent" type="my.parent">
   <sql name="parentId"/>
</field>
..
</class>

Hope this helps!

-Nick

On Mon, 08 Nov 2004 09:05:02 +0100, Andreas Vombach
<[EMAIL PROTECTED]> wrote:
> 
> Well, at least the first insert/get works, I really wonder why the
> second does not.
> My understanding is that Castor does a sort of (de)serialization in a
> String so the char storage should be ok?
> Maybe I could use a second table to solve the problem but as the array
> size is variable the number of columns had to be the max. array size.
> Just to illustrate, the following test run starts with an empty table:
> 
> C:\java\apps\jdotest>java jdotest
> store ok, id: 1
> test retrieved
> id: 1
> myarray: 1
> myarray: 2
> myarray: 3
> myarray: 4
> myarray: 5
> 
> C:\java\apps\jdotest>java jdotest
> db_ktrans: Castor JDO
> store ok, id: 2
> 
> 
> JDO queryException: org.exolab.castor.jdo.DataObjectAccessException:
> Type conver
> sion error: could not set value of FieldMolder of
> test.setmyarray(java.lang.Stri
> ng myarray) with value of type java.lang.String
> org.exolab.castor.jdo.DataObjectAccessException: Type conversion error:
> could no
> t set value of FieldMolder of test.setmyarray(java.lang.String myarray)
> with val
> ue of type java.lang.String
>         at
> org.exolab.castor.persist.FieldMolder.setValue(FieldMolder.java:330)
>         at org.exolab.castor.persist.ClassMolder.load(ClassMolder.java:720)
>         at org.exolab.castor.persist.LockEngine.load(LockEngine.java:356)
>         at
> org.exolab.castor.persist.TransactionContext.load(TransactionContext.
> java:649)
>         at
> org.exolab.castor.persist.QueryResults.fetch(QueryResults.java:229)
>         at
> org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.next(OQLQuer
> yImpl.java:697)
>         at
> org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.next(OQLQuer
> yImpl.java:670)
>         at jdotest.main(jdotest.java:46)
> java.lang.IllegalStateException: Transaction
> org.exolab.castor.jdo.engine.Transa
> [EMAIL PROTECTED] does not hold the read lock: test/1/1 -/-!
>         at
> org.exolab.castor.persist.LockEngine$TypeInfo.assure(LockEngine.java:
> 1279)
>         at
> org.exolab.castor.persist.LockEngine$TypeInfo.access$500(LockEngine.j
> ava:1011)
>         at
> org.exolab.castor.persist.LockEngine.revertObject(LockEngine.java:849
> )
>         at
> org.exolab.castor.persist.TransactionContext.rollback(TransactionCont
> ext.java:1720)
>         at
> org.exolab.castor.jdo.engine.DatabaseImpl.close(DatabaseImpl.java:255
> )
>         at jdotest.main(jdotest.java:76)
> 
> -----------------------------------------------------------
> 
> 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user
>



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to