I am trying to map the key in xml as follows:
<composite-id>
<key-property name="userId" column="USER_ID" />
<key-property name="passwordsBack" column="PASSWORDS_BACK" />
</composite-id>
I saw this construct without class = "BlahPK" in the documentation, in "Hibernate in Action" and elsewhere. When I try to get, I get:
Initial SessionFactory creation failed.org.hibernate.MappingException: composite-id class must implement Serializable: MyClass
This is a very simple data class, it has not been changed, I don’t need a key and, of course, I don’t want to redo my object and define a separate public class, just reading it with Hibernate. I currently have kludged to use rowid as id, but I would prefer the display to purely reflect how the table and object are used.
Disclaimer: I was looking for StackOverflow, and all I found was
how to handle hibernation with a combination key that simply says, “Don't do this, but you can.”
source
share