Error java.sql.SQLException: Numeric Overflow when Connect to Oracle using Hibernate

Got weird error today, here is the complere stacktrace

2018-01-31 12:14:56 WARN  SqlException: - SQL Error: 17026, SQLState: 99999
2018-01-31 12:14:56 ERROR SqlException: - Numeric Overflow

Caused by: java.sql.SQLException: Numeric Overflow
	at oracle.jdbc.driver.NumberCommonAccessor.throwOverflow(
	at oracle.jdbc.driver.NumberCommonAccessor.getInt(
	at oracle.jdbc.driver.GeneratedStatement.getInt(
	at oracle.jdbc.driver.GeneratedScrollableResultSet.getInt(
	at oracle.jdbc.driver.GeneratedResultSet.getInt(
	at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getInt(
	at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getInt(
	at org.hibernate.type.descriptor.sql.IntegerTypeDescriptor$2.doExtract(
	at org.hibernate.type.descriptor.sql.BasicExtractor.extract(
	at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(
	at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(
	at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(
	at org.hibernate.type.AbstractStandardBasicType.hydrate(
	at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(
	at org.hibernate.loader.Loader.loadFromResultSet(
	at org.hibernate.loader.Loader.instanceNotYetLoaded(
	at org.hibernate.loader.Loader.getRow(
	at org.hibernate.loader.Loader.getRowFromResultSet(
	at org.hibernate.loader.Loader.processResultSet(
	at org.hibernate.loader.Loader.doQuery(
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(
	at org.hibernate.loader.Loader.doList(
	... 75 more	

And here is my java class,

public class Class {
   private Integer value;

   // other setter and getter

How to solve the issue is actually quite simple, it’s all happen because im having a data on database which is bigger than Integer’s max value. Updating my bean from Integer to BigDecimal solve the problem,

public class Class {
   private BigDecimal value;

   // other setter and getter

No Comments

Leave a Comment

Please be polite. We appreciate that.
Your email address will not be published and required fields are marked

:-[ (B) (^) (P) (@) (O) (D) :-S ;-( (C) (&) :-$ (E) (~) (K) (I) (L) (8) :-O (T) (G) (F) :-( (H) :-) (*) :-D (N) (Y) :-P (U) (W) ;-)