Обсуждение: Bad value for type BigDecimal : Y

Поиск
Список
Период
Сортировка

Bad value for type BigDecimal : Y

От
Ashish Jain
Дата:
Hi,

I am using postgresql 8.3 with openJPA 1.2.1. I hit the following error

org.postgresql.util.
PSQLException: Bad value for type BigDecimal : Y
    at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toBigDecimal(AbstractJdbc2ResultSet.java:2710)
    at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBigDecimal(AbstractJdbc2ResultSet.java:2133)
    at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBigDecimal(AbstractJdbc2ResultSet.java:311)
    at org.tranql.connector.jdbc.ResultSetHandle.getBigDecimal(ResultSetHandle.java:179)
    at org.apache.openjpa.lib.jdbc.DelegatingResultSet.getBigDecimal(DelegatingResultSet.java:282)
    at org.apache.openjpa.jdbc.sql.DBDictionary.getBigDecimal(DBDictionary.java:389)
    at org.apache.openjpa.jdbc.sql.PostgresDictionary.getInt(PostgresDictionary.java:210)
    at org.apache.openjpa.jdbc.sql.DBDictionary.getChar(DBDictionary.java:556)
    at org.apache.openjpa.jdbc.sql.ResultSetResult.getCharInternal(ResultSetResult.java:288)
    at org.apache.openjpa.jdbc.sql.ResultSetResult.getObjectInternal(ResultSetResult.java:356)
    at org.apache.openjpa.jdbc.sql.AbstractResult.getObject(AbstractResult.java:662)
    at org.apache.openjpa.jdbc.meta.strats.HandlerStrategies.loadDataStore(HandlerStrategies.java:205)
    at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.load(HandlerFieldStrategy.java:172)
    at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:796)
    at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:833)
    at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:785)
    at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:453)
    ... 106 more



Please help!!!

Thanks
Ashish

Re: Bad value for type BigDecimal : Y

От
Richard Broersma
Дата:
On Thu, Jun 11, 2009 at 7:01 AM, Ashish Jain<ashjain2@gmail.com> wrote:

> I am using postgresql 8.3 with openJPA 1.2.1. I hit the following error
>
> org.postgresql.util.
> PSQLException: Bad value for type BigDecimal : Y     at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.toBigDecimal(AbstractJdbc2ResultSet.java:2710)

I'm curious what the column definition is for the mapped field that is
defined as a BigDecimal in your JPA ORM.  Is it possible for
PostgreSQL's numeric data to represent values that exceed the limits
of java BigDecimal class?


--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

Re: Bad value for type BigDecimal : Y

От
Ashish Jain
Дата:
Hi Richard,
 
Thanks for your reply!!

None of the fields are defind as Big Decimal.I have integer, character and timestamp as the variable types in my SQL statments
Thanks
Ashish
On Thu, Jun 11, 2009 at 10:00 PM, Richard Broersma <richard.broersma@gmail.com> wrote:
On Thu, Jun 11, 2009 at 7:01 AM, Ashish Jain<ashjain2@gmail.com> wrote:

> I am using postgresql 8.3 with openJPA 1.2.1. I hit the following error
>
> org.postgresql.util.
> PSQLException: Bad value for type BigDecimal : Y     at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.toBigDecimal(AbstractJdbc2ResultSet.java:2710)

I'm curious what the column definition is for the mapped field that is
defined as a BigDecimal in your JPA ORM.  Is it possible for
PostgreSQL's numeric data to represent values that exceed the limits
of java BigDecimal class?


--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

Re: Bad value for type BigDecimal : Y

От
Richard Broersma
Дата:
On Thu, Jun 11, 2009 at 9:39 AM, Ashish Jain<ashjain2@gmail.com> wrote:

> None of the fields are defind as Big Decimal.I have integer, character and
> timestamp as the variable types in my SQL statments

If your classes do not define BigDecimal as a field and your tables do
not have a numeric data type, it might be very difficult to find the
cause of this error.


--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

Re: Bad value for type BigDecimal : Y

От
Mikko Tiihonen
Дата:
Ashish Jain wrote:
> Hi,
>
> I am using postgresql 8.3 with openJPA 1.2.1. I hit the following error
>
> org.postgresql.util.
> PSQLException: Bad value for type BigDecimal : Y
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBigDecimal(AbstractJdbc2ResultSet.java:311)
>     at
> org.tranql.connector.jdbc.ResultSetHandle.getBigDecimal(ResultSetHandle.java:179)
>     at
> org.apache.openjpa.lib.jdbc.DelegatingResultSet.getBigDecimal(DelegatingResultSet.java:282)
>     at
> org.apache.openjpa.jdbc.sql.DBDictionary.getBigDecimal(DBDictionary.java:389)
>     at
> org.apache.openjpa.jdbc.sql.PostgresDictionary.getInt(PostgresDictionary.java:210)
>     at
> org.apache.openjpa.jdbc.sql.DBDictionary.getChar(DBDictionary.java:556)
>     at
> org.apache.openjpa.jdbc.sql.ResultSetResult.getCharInternal(ResultSetResult.java:288)

Do you store a boolean 'Y'/'N' in a char(1) column? Maybe openjpa needs to have
a different mapping that char for it.

-Mikko


Re: Bad value for type BigDecimal : Y

От
Ashish Jain
Дата:
Hi Mikko/Richard,
 
Thanks for your reply. I do have a column whose length is 1. The definition goes something like this
@Column(updatable=true, name="st_spom_status", nullable=false, length=1)
  private String status;
 
Do you think this is what may be the cause of the problem??
 
Thanks
Ashish

On Thu, Jun 11, 2009 at 10:22 PM, Mikko Tiihonen <mikko.tiihonen@nitorcreations.com> wrote:
Ashish Jain wrote:
Hi,

I am using postgresql 8.3 with openJPA 1.2.1. I hit the following error

org.postgresql.util.
PSQLException: Bad value for type BigDecimal : Y
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBigDecimal(AbstractJdbc2ResultSet.java:311)
   at org.tranql.connector.jdbc.ResultSetHandle.getBigDecimal(ResultSetHandle.java:179)
   at org.apache.openjpa.lib.jdbc.DelegatingResultSet.getBigDecimal(DelegatingResultSet.java:282)
   at org.apache.openjpa.jdbc.sql.DBDictionary.getBigDecimal(DBDictionary.java:389)
   at org.apache.openjpa.jdbc.sql.PostgresDictionary.getInt(PostgresDictionary.java:210)
   at org.apache.openjpa.jdbc.sql.DBDictionary.getChar(DBDictionary.java:556)
   at org.apache.openjpa.jdbc.sql.ResultSetResult.getCharInternal(ResultSetResult.java:288)

Do you store a boolean 'Y'/'N' in a char(1) column? Maybe openjpa needs to have a different mapping that char for it.

-Mikko


Re: Bad value for type BigDecimal : Y

От
John Lister
Дата:
Ashish Jain wrote:
> Hi Mikko/Richard,
>
> Thanks for your reply. I do have a column whose length is 1. The
> definition goes something like this
> @Column(updatable=true, name="st_spom_status", nullable=false, length=1)
>   private String status;
>
> Do you think this is what may be the cause of the problem??
>
My first guess is that you have a column defined as a bigdecimal in your
jpa object but it is actually a string in the database one of whose rows
contains the value 'Y'.

JOHN


Re: Bad value for type BigDecimal : Y

От
Ashish Jain
Дата:
John/Mikko/Richard,

Thanks a lot for all your help on this issue.
I was able to resolve this problem by setting the following property
<property name="openjpa.jdbc.DBDictionary" value="postgres(StoreCharsAsNumbers=false)"/>

Thanks
Ashish

On Fri, Jun 12, 2009 at 1:12 PM, John Lister <john.lister@kickstone.com> wrote:
Ashish Jain wrote:
Hi Mikko/Richard,
 Thanks for your reply. I do have a column whose length is 1. The definition goes something like this
@Column(updatable=true, name="st_spom_status", nullable=false, length=1)
 private String status;
 Do you think this is what may be the cause of the problem??
 
My first guess is that you have a column defined as a bigdecimal in your jpa object but it is actually a string in the database one of whose rows contains the value 'Y'.

JOHN