My struts based application has a feature to search results by date.
When i perform the search, I am getting the following error:
JDBCException W org.hibernate.util.JDBCExceptionReporter SQL Error: 17026, SQLState: null
JDBCException E org.hibernate.util.JDBCExceptionReporter Numeric Overflow
I am using java.util.Date as datatype for 'creationDate' field in my POJO, and timestamp as datatype in the mapping. I am working with Oracle.
I tried changing the datasource dialect from OracleDialect to Oracle9Dialect, but i stll get the same error.
The following is the code from my Action class:
if (request.getParameter("creationDate") != null && (request.getParameter("creationDate")).length() > 0) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
date = sdf.parse((String)request.getParameter("creationDate"));
}
catch (ParseException e) {
}
----
----
try {
session = PersistenceHelper.getNewSession();
Query query = session.getNamedQuery("com.entities.ac.ByDate");
query.setDate("date", date);
results = query.list();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
PersistenceHelper.closeSession(session);
} catch (HibernateException e) {
e.printStackTrace();
}
}
}
ac.hbm.xml
<hibernate-mapping>
<class name="com.entities.Ac" table="AC" lazy="false">
<id name="objectKey" type="long" column="OBJECT_KEY" unsaved-value="0" />
<property name="creationDate" type="timestamp" column="CREATION_DATE" />
<property name="withdrawalDate" type="date" column="WITHDRAWAL_DATE" />
</class>
<query name="com.entities.Ac.ByDate">
<![CDATA[
from com.entities.Ac as a
where a.creationDate >= to_date(:date, 'mm/dd/yyyy')
]]>
</query>
</hibernate-mapping>
hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<!-- Data Source -->
<property name="connection.datasource">java:comp/env/jdbc/PSOracle</property>
<property name="default_schema">PS_OWNER</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
Generated SQL
select ac0_.OBJECT_KEY as OBJECT1_, ac0_.CREATION_DATE as CREATION4_9_, ac0_.WITHDRAWAL_DATE as WITHDRAWAL5_9_ from EPS_OWNER.AC ac0_ where ac0_.CREATION_DATE>=to_date('05/29/2005', 'mm/dd/yyyy')
Any help in solving this problem would be greatly appreciated.
Thanks,
Kum
|