我正在尝试创建一个本地命名查询。我看到了链接
result-set-mapping-complex-mappings
<sql-result-set-mapping name="BookAuthorMappingXml">
<entity-result entity-class="org.thoughts.on.java.jpa.model.Author">
<field-result name="id" column="authorId"/>
<field-result name="firstName" column="firstName"/>
<field-result name="lastName" column="lastName"/>
<field-result name="version" column="authorVersion"/>
</entity-result>
<entity-result entity-class="org.thoughts.on.java.jpa.model.Book">
<field-result name="id" column="id"/>
<field-result name="title" column="title"/>
<field-result name="author" column="author_id"/>
<field-result name="version" column="version"/>
</entity-result>
</sql-result-set-mapping>
我拥有的列数超过20.是否可以一次性映射所有列
我正在使用hibernate 4.2
答案 0 :(得分:2)
你需要的是一个hibernate映射自动生成。 你可以关注mkyong的博客
https://www.mkyong.com/hibernate/how-to-generate-code-with-hibernate-tools/