Column without member

扶醉桌前 提交于 2019-12-12 01:49:37

问题


Using Hibernate we're trying to have it create an additional column to an abstract class - but we can't add a new member to this class (memory consumption in large scale). We need to have Hibernate create the schema (development phase, hibernate.hbm2ddl.auto=update).

Let's say we have a MyClass entity class with members a,b,c, and we would like Hibernate to also create a column d. This column is not needed in memory and will be accessed only via HQL/SQL during saving/loading times of MyClass instances.

Can this be done?

Notes:
1. Hibernate 3.6.0 Final + Oracle 11g + pure Java
2. We use annotations, no xml files


回答1:


Add the property to the class, but make it lazy (using the @Basic(fetch = FetchType.LAZY) annotation).

Make sure your classes are instrumented at build time: it's needed for this to work. More details are available in this chapter of the documentation.



来源:https://stackoverflow.com/questions/5145773/column-without-member

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!