-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Issue with NHMA: No name generated with id attribute
PostPosted: Tue Feb 28, 2006 1:26 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 11:38 am
Posts: 28
Hey guys,

I'm just switching over all my hbm files to NHM attributes since maintaining one instead of two files is much easier. Furthermore, I often can use typeof which simplifies things in case of refactorings.

So here is an issue that I ran into: With NHMA Property attributes I can neglect the Name parameter and NHMA will automatically generate the correct XML name attribute.

I tried to do the same thing with NHMA Id attributes, neglecting the Name parameter, NHMA won't generate the XML name attribute. One of the effects is that the ID property of my objects doesn't get populated.

I looked into the code and found the two methods WriteId and WriteProperty that generate the Mapping XML. WriteProperty writes a name attribute in every case and uses reflection if its not specified. WriteId only writes the name attribute if it's really specified.

I checked the NHibernate documentation and it states that name for id is optional whereas name for properties is mandatory. So, it seems NHMA is in line with the NHibernate specification.

What I'm wondering is in what cases would I specify an ID but not give it a name. As I said, the property in NHibernate didn't get populated so where's the point? Will NHibernate internally store the ID so that it's never exposed or what?

Thanks, Christoph


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 28, 2006 2:17 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes it's possible to use an entity without an identifier, you just have to supply the identifier value for every NHibernate operation that needs it (Save/Update).


Top
 Profile  
 
 Post subject: Issue with NHMA: No name generated with id attribute
PostPosted: Wed Nov 29, 2006 3:07 pm 
Newbie

Joined: Wed Nov 29, 2006 2:57 pm
Posts: 2
Location: Dallas
If there is an ID attribute decorating an actual property (rather than just the class) then it seems obvious to map the identifier to that property.

I guess it could get more complicated for compound identifiers, but if the HbmWriter checked for one and only one ID attribute in the class, and if that attribute is on a property, there is no reason not to map the identifier name to that property name.

Any chance of getting this added?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.