Hello, everybody !
I'm still having trouble while trying to get Castor to run. I tried to
execute a pretty straight-forward program (Test.java) which follows the jdo
example. (The plot was to try out how Castor deals with referential
integrity.) However, I get all kinds of errors which seem to have their
cause in the fact that the schema file I tried to have generated does not
match the mapping description. I'm pretty sure I have the mapping right by
now, so what's the proper .xsd ? As the attached create.sql states, I just
want to have a foreign key in a table. This can't be too difficult, can it.
Here is my latest error report:
[test] Loading mapping descriptors from file:/I:/Dokumente und
Einstellungen/R�diger/Eigene
Dateien/CastorTest/classes/test/test-mapping.xml
[test] SQL for creating test.db.Computer: INSERT INTO "computer"
("id","name") VALUES (?,?)
[test] SQL for deleting test.db.Computer: DELETE FROM "computer" WHERE
"id"=?
[test] SQL for updating test.db.Computer: UPDATE "computer" SET "name"=?
WHERE "id"=? AND "name"=?
[test] SQL for loading test.db.Computer: SELECT
"computer"."name","parts"."id" FROM "computer" LEFT OUTER JOIN "parts" ON
"computer"."id"="parts"."comp_id" WHERE "computer"."id"=?
[test] SQL for creating test.db.Part: INSERT INTO "parts"
("id","comp_id","name") VALUES (?,?,?)
[test] SQL for deleting test.db.Part: DELETE FROM "parts" WHERE "id"=?
[test] SQL for updating test.db.Part: UPDATE "parts" SET
"comp_id"=?,"name"=? WHERE "id"=? AND "comp_id"=? AND "name"=?
[test] SQL for loading test.db.Part: SELECT
"parts"."comp_id","parts"."name" FROM "parts" WHERE "parts"."id"=?
[test] Begin transaction
[test] SELECT "computer"."id","computer"."name","parts"."id" FROM "computer"
LEFT OUTER JOIN "parts" ON "computer"."id"="parts"."comp_id" WHERE
("computer"."id" = ?)
[test] java.lang.IllegalArgumentException: Collection Proxy doesn't exist
for it type
[test] java.lang.IllegalArgumentException: Collection Proxy doesn't exist
for it type
[test] at
org.exolab.castor.persist.CollectionProxy.create(ClassMolder.java:2956)
[test] at org.exolab.castor.persist.ClassMolder.load(ClassMolder.java:738)
[test] at org.exolab.castor.persist.LockEngine.load(LockEngine.java:361)
[test] at
org.exolab.castor.persist.TransactionContext.load(TransactionContext.java:54
5)
[test] at
org.exolab.castor.persist.QueryResults.fetch(QueryResults.java:229)
[test] at
org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.hasMore(OQLQueryImp
l.java:573)
[test] at
org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.hasMore(OQLQueryImp
l.java:556)
[test] at test.Test.run(Test.java:96)
[test] at test.Test.main(Test.java:54)
<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.exolab.org/mapping.dtd"> <mapping> <!-- Mapping for Product --> <class name="test.db.Computer" identity="id"> <map-to table="computer" xml="computer" /> <field name="id" type="integer"> <sql name="id" type="integer" /> <xml name="id" node="attribute"/> </field> <field name="name" type="string"> <sql name="name" type="char" /> <xml name="name" node="element" /> </field> <field name="part" type="test.db.Part" required="true" collection="array"> <sql many-key="comp_id" /> <xml name="part" node="element" /> </field> </class> <!-- Mapping for Product Detail --> <class name="test.db.Part" identity="id" depends="test.db.Computer"> <map-to table="parts" xml="part" /> <field name="id" type="integer"> <sql name="id" type="integer"/> <xml node="attribute"/> </field> <field name="computer" type="test.db.Computer"> <sql name="comp_id" /> <xml name="computer" node="element" /> </field> <field name="name" type="string"> <sql name="name" type="char"/> <xml node="text" /> </field> </class> </mapping>
create.sql
Description: Binary data
<?xml version="1.0"?> <!-- edited with XML Spy v3.0.7 NT (http://www.xmlspy.com) by Rüdiger Anlauf (noCom Ltd.) --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test.alcedis.de/CastorTest/Invoice"> <xsd:complexType name="PartType"> <xsd:sequence> <xsd:element name="id" type="xsd:int"/> <xsd:element name="name" type="xsd:string"/> <xsd:element name="computer" type="ComputerType"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ComputerType"> <xsd:sequence> <xsd:element name="id" type="xsd:int"/> <xsd:element name="name" type="xsd:string"/> <xsd:element name="part" type="PartType" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:schema>
Test.java
Description: JavaScript source
