1

I am trying to insert/select in hibernate,I have oracle db having column type TIMESTAMP(0) WITH LOCAL TIME ZONE in hibernate. I tried timestamp and date in xml mapping file and java pojo but I got this Exception:

org.hibernate.exception.GenericJDBCException: could not execute query
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.loader.Loader.doList(Loader.java:1525)
    at org.hibernate.loader.Loader.list(Loader.java:1505)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:400)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:791)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
    at com.rough.Main2.main(Main2.java:49)
Caused by: java.sql.SQLException: Session Time Zone not set!
    at oracle.jdbc.driver.TimestampltzAccessor.getDate(TimestampltzAccessor.java:159)
    at oracle.jdbc.driver.OracleResultSetImpl.getDate(OracleResultSetImpl.java:736)
    at oracle.jdbc.driver.OracleResultSet.getDate(OracleResultSet.java:1636)
    at org.hibernate.type.DateType.get(DateType.java:25)
    at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
    at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
    at org.hibernate.loader.hql.QueryLoader.getResultColumnOrRow(QueryLoader.java:339)
    at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:315)
    at org.hibernate.loader.Loader.doQuery(Loader.java:389)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208)
    at org.hibernate.loader.Loader.doList(Loader.java:1522)
    ... 6 more

This is my query : here column time is of TIMESTAMP(0) WITH LOCAL TIME ZONE

select a.id, coalesce(a.subject,' ') as subject, a.time from TblMsgAlert a where upper(a.toUserId) = :usern and a.status != :status and a.readFlag = :readFlag  and to_char(a.time) = (select e.curDate from TblEodBodStat e) order by a.id desc";

this is my mapping property in xml file

<property name="time" type="date">
            <column name="TIME" />
 </property>
Noman Akhtar
  • 690
  • 1
  • 12
  • 17

0 Answers0