Persistence inheritance question

Hi VP,

I have a problem with the following model:

  • One Class “CParent1” with a generalization class “CChild1”
  • One Class “CParent2” with a generalization class “CChild2”

All four classes with stereotype “ORM Persistable”

Then, ORM associaton bidirectional 1-to-many from CChild2 to CChild1
(see attached image)

If the inheritance strategy of both CParent1 (and its childs) and CParent2 (and childs) are the same, the code generation works well.

But, if both inheritance strategies are different, code generation fails with “Foreign Key and Association End classes not match”.

Is this a NHibernate limitation? or a bug in the code generator?

Many thanks
question.png

Hi distansia,

Unfortunately, we can’t reproduce your problem. In fact, the error message is not related to inheritance strategy, but about discriminator. In specific, it means that no discriminator has been defined for the super class. Could you send us your project to verify this problem?

Best regards,
Jick

Uhm… yes, that is the case. I defined no discriminator for any class because the program already does that when syncing to ERD :?:

But, let me re-test this again with the latest build you have pointed me to some posts before this.

I will be back with the answers.

I have just test this with the latest build (20071102e) and it has failed too!!

But you can not reproduce the problem, so I must have been doing something wrong.

I investigated further on and… voila! Here are the results:

  • If generating code from ORM Wizard, all discriminators for table-per-hierarchy left empty (as I did) are created setting it to the class name (ok). The code generation works well.

  • If generating code from “Generate Code…” (last option in ORM menu) the discriminators are not automatically set, and then the code generation fails. This was the path I was following lately to generate code, because you have more options available to set. Well, this path fails. But maybe this is what the “Generate Code…” is meant for. No automatically set anything.

Well, excuse me again. This time you discovered a bug in my way of doing things :smiley:

Anyway, it will be great if the error description includes what you told me. I mean “Discriminator not set (somewhere in the forest… sorry, I mean, project)”. Or even better, “Discriminator not set on CChild2” :roll:

Many thanks again, this time you have saved me lots of hours rechecking all my class inheritances on the project I’m using :wink:

Hi distansia,

Thank you for your reply. We will investigate this issue a.s.a.p.

Best regards,
Jick

Hello distansia,

This problem has been fixed, too. Please download and install the patch from the URL show in this thread:
http://forums.visual-paradigm.com/posts/list/2597.html

Best regards,
Jick

[quote=Jick]This problem has been fixed, too. Please download and install the patch from the URL show in this thread:
http://forums.visual-paradigm.com/posts/list/2597.html
[/quote]

Many thanks, I had discovered another bug much related to this one, but this release fixes it as well :-o

Good work!!!
(as always, I must add)

Hi distansia,

You’re welcome. Thank you very much for your effort! :smiley: :smiley: :smiley: :smiley: :smiley: (give you 5 smiles)

Best regards,
Jick