Problem with Native SQl queries : Hibernate 3.0.2

R

rakesh.cherukuri

Hi All,

In our project we are using the native SQL feature of hibernate.

The intention we had is to use the same binding xml file and the java
object class for similar queries (columns will differ) in different
functionalities.

However inside binding xml file hibernate is expecting that the query
inside sql-query element is fetching and mapping all the properties
defined in the class element. For example in the following xml file
binding

-------------------------------------------------------------------------------------
<hibernate-mapping>

<class name="com.ibm.hibernatepoc.mappings.AppName">
<cache usage="read-only" />
<id name="appName" type="string">
<generator class="assigned" />
</id>
<property name="name" type="string" />
</class>

<sql-query name="appNameQuery">
<return alias="appNames"
class="com.ibm.hibernatepoc.mappings.AppName" />
<![CDATA[ SELECT APP_NAME AS {appNames.appName} FROM APP
{appNames}]]>
</sql-query>

</hibernate-mapping>
-------------------------------------------------------------------------------------

if the query fetches and maps both the properties defined in class
element (ie. appName and name), hibernate works just fine. However the
query in the example is throwing the error because it is not fetching/
mapping the 'name' property.

Please let me know a solution to this. If this works fine then we can
use the same methodology in order to reuse the code for queries which
are querying the same DB.

Thanks a lot in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top