max wrote:
you haven't posted much about the query, the mapping etc. so not much i can help with :)
...but i can say that select new ofcourse uses the mapping files as the HQK query still needs to be translated into the proper sql.
You're right Max, I didn't give you much to work with. It's just that the Query is joining 6 tables and returning columns from each of them and I didn't want to sent more then necessary.
Here's the mapping file from which the SybTimestamp's coming from (look for name="changeDate"):
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="hibernate.Form"
table="FORMS"
>
<id
name="formId"
type="java.lang.Long"
column="Form_ID"
>
<generator class="assigned" />
</id>
<property
name="cid"
type="java.lang.Integer"
column="CID"
not-null="true"
length="6"
/>
<property
name="formLanguage"
type="java.lang.String"
column="Form_Language"
not-null="true"
length="1"
/>
<property
name="formStatus"
type="java.lang.String"
column="Form_Status"
not-null="true"
length="1"
/>
<property
name="transferredToAmisDate"
type="java.sql.Timestamp"
column="Transferred_To_AMIS_Date"
length="23"
/>
<property
name="transferredToAmisIndicator"
type="java.lang.String"
column="Transferred_To_AMIS_Indicator"
length="1"
/>
<property
name="createUserId"
type="java.lang.String"
column="Create_User_ID"
not-null="true"
length="3"
/>
<property
name="createDate"
type="java.sql.Timestamp"
column="Create_Date"
not-null="true"
length="23"
/>
<property
name="changeUserId"
type="java.lang.String"
column="Change_User_ID"
not-null="true"
length="3"
/>
<property
name="changeDate"
type="java.sql.Timestamp"
column="Change_Date"
not-null="true"
length="23"
/>
<!-- associations -->
<!-- bi-directional many-to-one association to Application -->
<many-to-one
name="application"
class="hibernate.Application"
not-null="true"
>
<column name="Appl_ID" />
</many-to-one>
<!-- bi-directional many-to-one association to WebSubsystem -->
<many-to-one
name="webSubsystem"
class="hibernate.WebSubsystem"
not-null="true"
>
<column name="Subsystem_ID" />
</many-to-one>
</class>
</hibernate-mapping>
I checked the datatype of that column in the resultset (I called the same HQL without the SELECT NEW). I did a getClass().getName() on the column and it returned "com.sybase.jdbc2.tds.SybTimestamp".
Here's the HQL:
Iterator it = session.createQuery(
"select new portFolio.PortFolioBean2( Form.application.applId, " +
"Application.programId, " +
"Application.applTitle, " +
"Form.cid, " +
"Form.webSubsystem.subsystemId, " +
"Application.letterOfIntentInd, " +
"Cod.shortNameFrench, " +
"Cod.shortNameEnglish, " +
"WebSubsystem.displayNameFrench, " +
"WebSubsystem.displayNameEnglish, " +
"Form.formStatus, " +
"Form.formLanguage, " +
"Form.changeDate, " +
"Form.formId) " +
"from Application Application, " +
"WebSubsystem WebSubsystem, " +
"WebSubsystemCrossref WebSubsystemCrossref, " +
"Cod Cod, " +
"Person Person, " +
"Form Form " +
"WHERE ( Application.grantType *= Cod.code) and " +
"( Application.programId = WebSubsystem.program.programId ) and " +
"(WebSubsystem.subsystemId = WebSubsystemCrossref.comp_id.bySubsystemId) AND " +
"( Application.webId = Person.cid ) and " +
"( Form.webSubsystem.subsystemId = WebSubsystem.subsystemId ) and " +
"( Form.application.applId = Application.applId ) and " +
"( Application.webId = Form.cid ) and " +
"( ( Application.webId = 12345 ) AND " +
"( (WebSubsystem.grantType = Application.grantType OR " +
"Application.grantType is null) AND " +
"(Application.letterOfIntentInd is null OR " +
"Application.letterOfIntentInd = WebSubsystem.letterOfIntentInd)) AND " +
"WebSubsystemCrossref.comp_id.byPortfolioSubsystemId = 56 AND " +
"Application.finalReportInd = 'N' ) AND " +
"DATEDIFF(day,Form.changeDate, getdate()) < 120 " +
"order by 2 ASC, 3 ASC, 1 ASC ").list().iterator();
Here the portFolio.PortFolioBean2 class:
public class PortFolioBean2 {
private Integer web_id;
private Long appl_id;
private Integer program_id;
private Integer subSystem_id;
private Long form_id;
private String appl_title;
private String letter_Of_Intent_Ind;
private String grantType_f;
private String grantType_e;
private String formName_f;
private String formName_e;
private String formLanguage;
private String form_Status;
private Timestamp change_Date;
/* Default constructor*/
public PortFolioBean2() {
}
/* constructor for loading all fields*/
public PortFolioBean2(Long appl_id, Integer program_id, String appl_title,
Integer web_id, Integer subSystem_id,
String letter_Of_Intent_Ind, String grantType_f,
String grantType_e, String applTitle_f,
String applTitle_e, String form_Status,
String formLanguage, Timestamp change_Date,
Long form_ID) {
this.appl_id = appl_id;
this.program_id = program_id;
this.appl_title = appl_title;
this.web_id = web_id;
this.subSystem_id = subSystem_id;
this.letter_Of_Intent_Ind = letter_Of_Intent_Ind;
this.formName_f = grantType_f + applTitle_f;
this.formName_e = grantType_e + applTitle_e;
this.formLanguage = formLanguage;
this.form_Status = form_Status;
this.change_Date = change_Date;
this.form_id = form_ID;
}
I tried changing the column's datatype in the mapping and the PortFolioBean2 constructor to "com.sybase.jdbc2.tds.SybTimestamp" and that didn't solved the problem.
Cheers