Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.5
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>
<class name="com.eclasia.wos.domain.Product" table="ELOGFP.STPROD1P">
<id name="code" column="BAPROD">
<generator class="assigned"/>
</id>
<property name="name" column="BANAME"/>
<property name="category" column="BACATG"/>
<property name="country" column="BACTRY"/>
</class>
</hibernate-mapping>
Name and version of the database you are using: AS400 DB2 V5R1
The generated SQL (show_sql=true):
Hibernate: select this_.BAPROD as BAPROD0_, this_.BANAME as BANAME2_0_, this_.BACATG as BACATG2_0_, this_.BACTRY as BACTRY2_0_ from ELOGFP.STPROD1P this_ where this_.BAPDST=? and this_.BASUPP=? order by this_.BAPROD asc fetch first 50 rows only
I would like to create a new MyOrder class, override the class
org.hibernate.criterion.Order
such that the MyOrder.toSqlString() will return the column alias "order by BAPROD0_ asc" instead of "order by this_.BAPROD asc" which contains the table alias followed by the column name.
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
StringBuffer fragment = new StringBuffer();
.....
return fragment.toString();
}
How can I do this with the CriteriaQuery / CriteriaQueryTranslator??
Your help is greatly appreciated.