Vishal Shanbhag
2005-02-08 18:43:45 UTC
Hello,
We have a "non-identifying optional relationship"
between 2 entities A & B which has cardinality "one to
many" from A to B. Middlegen correctly identifies the
relationship but when it generates the hibernate
mapping file for B, it sets the "non-null" attribute
to "true" in the many-to-one association field it puts
in B.
Since A-B is an "optional" relationship, we can have
rows in the table B that have the foreign key from
table A set to null. But when hibernate tries to save
B, it throws an exception saying "non-null attribute
is null". Hence hibernate is enforcing a constraint
which doesnt really exist in the underlying database.
My questions are :
Is it possible to configure the "non-null" attribute
of a relationship through middlegen?
Is there a way to solve this problem without having to
manually edit the hibernate mapping files before
generation the java files?
Best
Vishal
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com
We have a "non-identifying optional relationship"
between 2 entities A & B which has cardinality "one to
many" from A to B. Middlegen correctly identifies the
relationship but when it generates the hibernate
mapping file for B, it sets the "non-null" attribute
to "true" in the many-to-one association field it puts
in B.
Since A-B is an "optional" relationship, we can have
rows in the table B that have the foreign key from
table A set to null. But when hibernate tries to save
B, it throws an exception saying "non-null attribute
is null". Hence hibernate is enforcing a constraint
which doesnt really exist in the underlying database.
My questions are :
Is it possible to configure the "non-null" attribute
of a relationship through middlegen?
Is there a way to solve this problem without having to
manually edit the hibernate mapping files before
generation the java files?
Best
Vishal
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com