Here's a fun head-scratcher to start the month of May off!
I have a hibernate mapping like so:
<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!
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.