I am trying to persist a table using a hibernate xml mapping file with the id field set as access="noop". I am doing this because I don't want the primary key field to be in the class file. The classes I am persisting are from a third party library and if I change them it will be a maintenance nightmare when the third-party library is updated. I was hoping that I could persist the relations between objects without altering the java class files.
ie
<hibernate-mapping>
<class name="blah" table="blah">
<id name="blah_id" type="long" access="noop" >
<column name="BLAH_ID" />
<generator class="native" />
</id>
<property name="value" type="double">
<column name="VALUE" />
</property>
</class>
</hibernate-mapping>
Unfortunately this doesn't quite work, the noop access specifier requests that hibernate never access the field but hibernate still tries to write a value there when the save function returns causing the following error;
identifier of an instance of third.party.object was altered from 2 to null
I could write a wrapper for the third part libraries, inheriting all the classes and adding the fields for the relations, but I was really hoping for a better solution.
It seems reasonable to want to keep the pks out of the classes. How do I do that?
Any ideas?
我认为组件类是您正在寻找的较早的自我。
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.