Hi,
I use NaturalIds for all my objects and have recently run into an issue. Some of my objects define their uniqueness through a homogeneous collection of objects. Unfortunately when I map this collection with @ManyToMany as well as @NaturalId then I get the following error:
Caused by: org.hibernate.MappingException: Unable to find logical column name from physical name null in table MyClass at org.hibernate.cfg.Mappings.getLogicalColumnName(Mappings.java:514) at org.hibernate.cfg.IndexOrUniqueKeySecondPass.doSecondPass(IndexOrUniqueKeySecondPass.java:61) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1136) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:324) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121) ...
Which leads me to believe that NaturalId-ing a ManyToMany is simply not supported. Can anyone confirm this? I was unable to find anything on the topic within the Core or Annotations documentation.
If this is not allowed, does anyone have any clever ideas on how I can still make uniqueness based on a set of objects? Although the more I think about it this whole attempt does not sound like something one would like to do in SQL... if that is the answer than I will be willing to accept such an answer.
Thank you.
Apologies if I missed any important information but since my question is pretty general (I hope) I figured details don't matter... pardon me if I am incorrect in my assumption.
|