Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: getPropertyNames returns empty...
PostPosted: Tue May 01, 2012 1:58 pm 
Newbie

Joined: Tue May 01, 2012 1:48 pm
Posts: 2
Hi there,
I'm experiencing an issue with hibernate 3.6.7 where getPropertyNames returns an empty list if all attributes are part of the key.

Specifically, I have a hibernate mapping like this:
Code:
<hibernate-mapping default-lazy="false">   
  <class name="my.class.name" table="MY_CLASS_TABLE">     
    <composite-id>       
      <key-property name="prop1" column="PROP_1" />       
      <key-property name="prop2" column="PROP_2" />       
      <key-property name="prop3" column="PROP_3" />     
    </composite-id>   
  </class>
</hibernate-mapping>


And a function that goes through and builds a "dictionary" of class names and properties. I have no problems until I get to this class, and for some reason, my call to getPropertyNames() returns an empty list. If there is at least one property outside the composite-id, I don't have any problems. The kludgy work-around I have is to add a dummy field outside the id (yuck!) and suddenly everything works.

Any idea why this is happening and what I can do to solve it?

Thanks in advance for your help!

Also, if you prefer, this is cross-posted from stackOverflow: http://stackoverflow.com/questions/1040 ... ibutes-are


Top
 Profile  
 
 Post subject: Re: getPropertyNames returns empty...
PostPosted: Thu May 03, 2012 6:22 pm 
Newbie

Joined: Tue May 01, 2012 1:48 pm
Posts: 2
After further digging, I found getIdentifierType() and getIdentifierPropertyName() do the job. For a composite key like this one, I check the type to see if it's an instance of CompositeCustomType or ComponentType, and if it is, throw it into a temporary var, and call getPropertyNames() on that temporary var.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 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.