Hello,
I've got a simple mapping question for you more experienced Hibernate users...
In my old legacy DB, I have two tables - one defining Mail Triggers, and one for Mail Content. Each trigger (usually) is associated to one MailContent row through the use of a non-enforced foreign key (mysql).
I configured MailTriggers to have a many-to-one relationship to MailContent, and this normally works great. I load a MailTrigger, and I have direct access to the mail content data (two rows were loaded automatically for me - one from each table).
Trouble is when that foreign key is null! Having mail content defined for each mail trigger is in fact optional.
In this case, hibernate throws an exception, and doesn't return data from either table!
What should I do? I have "worked around" the problem by using lazy initialization, but I'm not sure this is the good solution...
It would better suit our data model if the related item were set to null.
Thanks!
Mal.
|