Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Hibernate 3.0 final
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.abcd.webservices.servicename.dao.hibernate">
<class name="InformationRequestedAtDetailLevel" table="INTRNL_AND_EXTRNL_DETL">
<composite-id>
<key-property name="ieId" column="intrnl_and_extrnl_id" />
<key-property name="ieSlNumber" column="intrnl_and_extrnl_sl_nbr" />
<key-property name="ieOcNumber" column="intrnl_and_extrnl_oc_nbr" />
<key-property name="ieTabCode" column="intrnl_and_extrnl_tab_cd" />
<key-property name="ieItemCode" column="intrnl_and_extrnl_itm_cd" />
</composite-id>
<property name="ieVendCode" column="intrnl_and_extrnl_vend_cd"/>
<property name="ieDetailDesc" column="intrnl_and_extrnl_detail_desc"/>
<query name="ByManyParameters">
select ieTabDetail
from InformationRequestedAtDetailLevel as ieTabDetail
where
ieTabDetail.ieId = :ieId and
ieTabDetail.ieSlNumber = :ieSlNumber and
ieTabDetail.ieOcNumber = :ieOcNumber and
ieTabDetail.ieVendCode = :ieVendCode and
ieTabDetail.ieTabCode = :ieTabCode
</query>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
SessionFactory is setup via Spring's applicationContext and Spring managed data source. The named query is run via the following method--
private Collection _findIntExtList(MyBusinessObject mBo) {
return getHibernateTemplate().findByNamedQueryAndNamedParam(
"com.abcd.webservices.servicename.dao.hibernate.InformationRequestedAtDetailLevel.ByManyParameters",
new String[] {"ieId", "ieSlNumber", "ieOcNumber", "ieVendCode", "ieTabCode" },
new Object[] {mBo.getIeId(), mBo.getIeSlNumber(), mBo.getIeOcNumber(), mBo.ieVendCode(), mBo.ieTabCode()}
);
}
Full stack trace of any exception that occurs:
Not Applicable
Name and version of the database you are using:
64-Bit DB2 9.1.4 running on AIX
The generated SQL (show_sql=true):
Not Applicable
Debug level Hibernate log excerpt:
Not Applicable
Problems with Session and transaction handling?
No
The question:
I'm writing a web service where I'll run a query via HQL named query. This query gets me a collection of objects that contain code and description. What I have to send back to the client is an array (or collection) of string that contains code + "-" + description format of what I got back from the query. I currently loop thru something like this (look at the while loop).
public Collection theDaoFindCaller(MyBusinessObject mBo) {
Collection ieTabDetailArrayList = new ArrayList();
Collection infoAtDetailLevel = _findIntExtList(mBo);
Iterator infoAtDetailLevelIt = infoAtDetailLevel.iterator();
while (infoAtDetailLevelIt.hasNext()) {
InformationRequestedAtDetailLevel infoReqAtDetLevel = (InformationRequestedAtDetailLevel)infoAtDetailLevelIt.next();
ieTabDetailArrayList.add(infoReqAtDetLevel.getIeItemCode() + "-" + infoReqAtDetLevel.getIeDetailDesc());
}
return ieTabDetailArrayList;
}
Can I some how avoid the loop that I have to go thru to concatenate two strings and have hibernate generate as a pseudo-column on-the-fly. With JDBC, I could have added this pseud-column to my selection column list and have added a field at the row mapper level, so I wouldn't have to do anything more.
I searched for the forum and google'd for an appropriate article, without luck. I appreciate if some one could send me some kind of try-out-solutions or links that could have more information, that would be very helpful.
Thanks for your time!