Castor gods,
I have looked at the examples and have scoured the mail-list archives and
can't seem to find an answer to the following Many-to-Many problem. I'll
build on the N:M example that is provided in the Castor examples:
Categories and Products have an N:M relationship. That means that there
needs to be a 3rd table, in this case, "category_prod" that holds the N:M
relationship instances. Fine. But what if the "category_prod" table has
additional data columns (which they typically do) and that are REQUIRED?
>From the example file: \castor-0.9.4\examples\jdo\mapping.xml
The perspective from the Categories side is:
<field name="categories" type="myapp.Category" required="true"
collection="vector" direct="false" lazy="false" transient="false">
<sql name="category_id" many-table="category_prod" many-key="prod_id"
read-only="false" dirty="check" transient="false" />
<xml name="category" node="element" />
</field>
The perspective from the Products side is:
<field name="products" type="myapp.Product" required="true"
collection="vector" direct="false" lazy="false" transient="false">
<sql name="prod_id" many-table="category_prod" many-key="category_id"
read-only="false" dirty="check" transient="false" />
<xml name="product" node="element" />
</field>
Ideally, I would think there should be a way to define the mapping for the
N:M table, "category_prod" and map that to a Java class that can handle
setting necessary fields as it is constructed.
Currently, if my N:M table, "category_prod" has an extra column in it that
is REQUIRED, then a db.create(<product or category type instance>) will fail
with a
java.sql.SQLException: ORA-01400: cannot insert NULL into
("USERNAME"."PRODUCT / CATEGORY"."CATEGORY_PROD") type error
Will coding up a CREATE method get me around this problem? Is there some
additoinal mapping info I can give to have this done automagically?
Please advise.
Bart Jenkins
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev