|
Hi,
Somehow my message got corrupted, due to Outlook
Express..
Anyways I found the proper solution browsing the
list archives:
upgrade to the CVS-snapshot.
IMHO, releasing any nightly-build as Castor 0.9.4
would be the best decision.
The answer for nearly all Castor problems is
"upgrade to cvs".
My original problem was that castor wasn't able to
map a 1:n relationship from one entity to itself:
julian
Hi,
I'm trying to map a 1:n relationship from one
entity to itself e.g.
CREATE TABLE TEST(uoid NUMBER(10),NAME
VARCHAR2(50),parentID NUMBER (10));
ALTER TABLE TEST ADD ( CONSTRAINT FK_TEST FOREIGN
KEY (parentId) REFERENCES Test (uoid))
Creating of instances , and subInstances works
fine.
But when I'm trying to load the instances using a
simple OQL query ("SELECT t FROM test t") or db.load it fails,because
CASTOR builds an invalid SQL-statement:
[test] SQL for loading Test: SELECT
"TEST"."NAME" WHERE "TEST"."UOID"="TEST"."PARENTID"(+) AND
"TEST"."UOID"=?
Nested error: java.sql.SQLException:
ORA-01416 two tables cannot be outer-joined to each other
[test] while executing SELECT TEST"."NAME"
FROM "TEST" WHERE "TEST"."UOID"="TEST"."PARENTID"(+)
my mapping looks like this:
<class
name="Test"
identity="uoid" key-generator="SEQUENCE"> <description>Branche</description> <map-to table="Branche" xml="Branche" /> <field name="uoid" type="integer" > <sql name="uoid" type="integer"/> <xml node="attribute"/> </field> <field name="name"
type="string">
<sql name="Name" type="varchar" /> <xml node="text" /> </field> <field name="subTest" type="Test"
required="false"
collection="collection"> <sql many-key="parentid"/> <xml name="subBranches" node="element" /> </field> <field name="parentTest" type="Test" required="false"> <sql name="parentid" /> <xml name="parent" node="element" /> </field> </class>
Note that creating/inserting of values works just
the SQL to load the object is broken. Have I made a mistake with the
mappings???
I tried several variations of the mapping above but
none did work.
or, is there any way to circumvent the standard
OQL->SQL mapping castor performs??
julian
|
