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.
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.