-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Date/Time issue with Oracle and SQLServer 2005
PostPosted: Thu May 29, 2008 6:43 am 
Newbie

Joined: Thu May 29, 2008 6:24 am
Posts: 5
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 29, 2008 9:20 am 
Newbie

Joined: Fri Apr 04, 2008 2:17 pm
Posts: 15
Are you using the right dialect in your hibernate.cfg.xml?

For instance, if you have Oracle9i, make sure your dialect is Oracle9i and not Oracle9 or something else:
<property name="dialect">org.hibernate.dialect.Oracle9iDialect</property>

Specifically, in the case of Oracle9, I've read of date/timestamp fetching bugs.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.