I had a problem when testing your software that I want you to know. When designing a class hierarchy, I had some problems when changing the inheritance strategy between “table-per-subclass” and “table-per-class-hierarchy”.
The DBVA version I have tested this with is: v4.1 (sp1_20071119k) (downloaded from a forum link).
I have prepared an image to show you the effect, I think it is clearer if pictured than only writing about it 8)
The problem appears when two different subclasses have a reference with multiplicity 1 or 1…* (so, nullable=false). If “table-per-subclass” selected, no problem. But what happens if “table-per-class-hierarchy” is set? :?
- The generated code is OK (in fact, it is the same)
- The generated ORM Mapping “seems” ok but… :?
- When you try to save a subclass instance…
“PersistentException” OMG :evil:
Why? Because NHibernate (I am generating C# code) tries to save a NULL value into a nullable=false database field. What? :shock:
Looking at the problem, the solutions seems clear:
- if “table-per-class-hierarchy” then all references should be nullable, despite the user has set in the model.
In fact, you already do this in attributes. I mean, if a “double” attribute is on a subclass, then the generated code is “double?” (shorthand in C# for nullable double type).
Well, having said this, is this a bug or a “feature” we all should be aware of? (maybe they are some rare cases when the above solution should not apply) :?:
Thanks for reporting this problem. Our engineers are investigating on this issue and I’ll get back to you ASAP once there are any news on it. Thanks!
I wold like to let you know this problem has been fixed. In the latest version we allow having nullable to FK column when creating FK (initial sync from class to ERD). You can always change the nullable to false at anytime in case you need. You can download the latest build at the following link. Please let me know it works or not. Thanks in advance!
I have just tested this and I think it will work (although I could not test it with existing code… yet. I will do ASAP). Good work!! and the ORM Message is informative enough! Bravo!
BTW, let me tell you one typo in the ORM message. It says “side will syncrhonzied” :oops:
And one question, how can I erase that messages? Once they are there, I can not delete all of them with right click :?:
Thanks for reporting the typo. Our engineers had fixed it up and it will available in the next release. About removing the message, you can right click on the message or the message pane and select “Remove Selected Logs” or “Clear Logs”. If you need any help, please let me know.
I would like to let you know the type issue has also being fixed and please find the new build at the following link. If you need any help, please do not hesitate to contact me again.