Ursan Ionut Ursan Ionut - 6 months ago 25
Java Question

Hibernate createSqlQuery without getting the blob data from database - "NumberFormatException" on query.list()

Shortly ..I have a web app that queries an Oracle database and displays the result on a page. The problem is that I get a

NumberFormatException
when retrieving the data with
query.list()
, this happens only on some tabels. I`ve searched and found out that this is happening because some of my tabels contains BLOB and CLOB data so ..

Is there any way I can tell hibernate to search on my DB with createSqlQuery(sqlString) without retrieving the BLOB and CLOB data from my DB ?


Here is a part of my code :

Query query = session.createSQLQuery(sqlQuery).setFetchSize( Integer.valueOf(nrOfLines) );
query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
final List<Map<String, String>> resultQueryList = query.list();


NumberFormatException stacktrace:

{java.lang.NumberFormatException@2747}Method threw java.lang.NumberFormatException' exception.
detailMessage = {java.lang.String@2875} "For input string: "4294967295""
cause = {java.lang.NumberFormatException@2747}"java.lang.NumberFormatException: For input string: "4294967295""
{java.lang.StackTraceElement@2751} "java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)"
{java.lang.StackTraceElement@2752} "java.lang.Integer.parseInt(Integer.java:495)"
{java.lang.StackTraceElement@2753} "java.lang.Integer.parseInt(Integer.java:527)"
{java.lang.StackTraceElement@2754} "oracle.jdbc.driver.OracleResultSetMetaData.getPrecisionOracleResultSetMetaData.java:303)"
{java.lang.StackTraceElement@2755} "org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:581)"
{java.lang.StackTraceElement@2756} "org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:508)"
{java.lang.StackTraceElement@2757} "org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:524)"
{java.lang.StackTraceElement@2758} "org.hibernate.loader.Loader.getResultSet(Loader.java:1821)"
{java.lang.StackTraceElement@2759} "org.hibernate.loader.Loader.doQuery(Loader.java:697)" .......


I`ve searched a lot but found only how to read blob and clob data from DB... and what I want is exacly the opposite.

Answer

Finally found out a way to do it. I followed this article http://alessandromigliaccio.blogspot.ro/2010/11/javalangnumberformatexception-for-input.html and added to tomcat 7 the option -Doracledatabasemetadata.get_lob_precision=false

Comments