Hi,
Thanks for pointing this out! I just confirmed that this is a bug.
Validation of mandatory to-one relationships is skipped:
http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-124 . This is
fixed and will be included in tomorrow's nightly build and subsequent
releases.
Andrus
On May 11, 2004, at 6:46 PM, Mehdi Bennani wrote:
> Hi guys,
>
> I am pretty new to Cayenne, and I have a quick one for your guys. I
> downloaded/running 1.1.
> I am having a problem with Validation. Say I have 2 entities
> Department and Employee.
> There is a 1 to many relationship between employee and dep. (1 emp
> belongs to many dep). This relationship exists between the following
> fields:
>
> emp.depId and dep.depId.
>
> Now, I have set emp.depId to be isMandatory = true. I.e: I want to
> enforce that you cannot add an employee without its departement id.
>
> Later, in the code, in a test client class: I am creating an employee
> and trying to commit it.
> >> Result: It allows me to do so (i.e: I only get a
> cayenneruntimeexception instead of the expected validationexception)!!
> So, it does not catch the error
>
> until it tries to run the insert against the db...!!
>
> Now, curious to see validation working, I tried to set another
> employee field emp.empName ( which is the employee name) to be
> isMandatory=true, and that worked. i.e: validationexception kicked in
> as expected.
>
> So, it seems to me that fieds others than PKs and FKSs are being
> validated against the isMandatory, but not the ones involded in
> relationships.
>
> Can you guys give me a hand...
>
> Sincerely,
>
> Mehdi Bennani
> Software Engineer
> FreeBalance Inc.
> Visit the new FreeBalance website..www.FreeBalance.com
>
> T (613) 236-5150 ext.325
> F (613) 236-7785
> mbennan..reeBalance.com
>
> This email message is for the sole use of the intended recipient(s)
> and may contain confidential and privileged information. Any
> unauthorized review, use, disclosure, or distribution is prohibited.
> If you are not the intended recipient(s) please contact the sender by
> reply email and destroy all copies of the original message and any
> attachments.
This archive was generated by hypermail 2.0.0 : Wed May 12 2004 - 09:20:50 EDT