Column without member

2019-09-01 16:08发布

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条回答
做自己的国王
2楼-- · 2019-09-01 16:49

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.

查看更多
登录 后发表回答