Sunday, April 9, 2017

hibernate native query mapping

Leave a Comment

I am trying to make a native named query.I saw the link

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> 

the number of columns i have is more than 20.Is there is way to map all columns in one go

I am using hibernate 4.2

1 Answers

Answers 1

What you need is an hibernate mapping auto generation. You can follow the blog from mkyong

https://www.mkyong.com/hibernate/how-to-generate-code-with-hibernate-tools/

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment