Hi
This problem what i am facing seems to be very trivial , but I am not able to think of Solution after going through All the docs.
I have the following hbm/Java code for a table.
<class name="SystemHealthErrorState" table="S3_ERROR_STAT" lazy="true">
<composite-id name="errorStatPK"
class="SystemHeathErrorStatPK"
access="field">
<key-property name="systemController"
access="field"
type="string"
length="40"
column="SYSTEM_CONTROLLER"/>
<key-property name="callName"
access="field"
type="string"
length="40"
column="CALL_NAME"/>
<key-property name="logTime"
access="field"
column="LOG_TIME"/>
<key-property name="errorType"
access="field"
type="string"
length="10"
column="ERROR_TYPE"/>
</composite-id>
<property name="callType"
column="CALL_TYPE"
type="string"
length="40"
access="field"/>
<property name="errorRecoveredTime"
column="ERROR_RECOVERED_TIME"
access="field"/>
<property name="errorCount"
column="ERROR_COUNT"
access="field"/>
<property name="outageFlag"
column="OUTAGE_FLAG"
access="field"/>
</class>
</hibernate-mapping>
public class SystemHealthErrorState implements Serializable, Comparable, S3Entity,
Cloneable {
private String callType;
private Date errorRecoveredTime;
private Integer errorCount;
private char outageFlag;
private SystemHeathErrorStatPK errorStatPK = new SystemHeathErrorStatPK();
.......................
..............................
..........................
}
public class SystemHeathErrorStatPK implements Serializable, S3Entity,
Cloneable {
private String systemController;
private String callName;
private java.util.Date logTime;
private String errorType;
........................
..............................
.........................
}
In the Hibernate DAO's i run following login to get the Data..
getCount(String systemController, java.sql.Date startTime, java.sql.Date endTime) {
Type[] type = {Hibernate.TIME, Hibernate.TIME;}
Criteria crit = null;
String errorType = "OUTAGE";
Criterion scName = Expression.sql("{alias}.SYSTEM_CONTROLLER = ?", systemController, Hibernate.STRING);
Date[] dateVal = { startTime, endTime};
Criterion logLe = Expression.sql("{alias}.log_time between ? and ?", dateVal, type);
Criterion errType = Expression.sql("{alias}.ERROR_TYPE = ?", errorType, Hibernate.STRING);
if(systemController.equalsIgnoreCase("All")){
crit = getSession().createCriteria(SystemHealthErrorState.class).add(errType).add(logLe);
}else{
crit = getSession().createCriteria(SystemHealthErrorState.class).add(scName).add(errType).add(logLe);
}
Integer cnt = (Integer) crit.setProjection(Projections.rowCount()).uniqueResult();
return cnt.intValue();
}
The issue is with Hibernate types.
If I use type as Hibernate.TIME and Hibernate.Date , SQL Server 2005 doesnot return data. And If I use Hibernate.TIMESTAMP Oracle does not return data. I am making sure that I have the data present between the dates.
Can any one let me know , where I am going wrong?
Ankit
|