Using native sql in Native SQL Hibernate -


i have complex sql planning integrate , going integrateing hibernate through named query please advise can write native sql in hbm.xml file inside ..

<![cdata[  ] tag , in pojos  retrieve  session.getnamedquery , 

please advise native sql approach best 1 ..!! want keep query in xml

here how in xml file:

<!-- stock.hbm.xml --> <hibernate-mapping>     <class name="com.mkyong.common.stock" table="stock" ...>         <id name="stockid" type="java.lang.integer">             <column name="stock_id" />             <generator class="identity" />         </id>         <property name="stockcode" type="string">             <column name="stock_code" length="10" not-null="true" unique="true" />         </property>         ...     </class>     <sql-query name="findstockbystockcodenativesql">   <return alias="stock" class="com.mkyong.common.stock"/>   <![cdata[select * stock s s.stock_code = :stockcode]]>   </sql-query>  </hibernate-mapping> 

using query

query query = session.getnamedquery("findstockbystockcodenativesql") .setstring("stockcode", "7277"); 

read here


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -