Re: Require assistance in Postgres + Hibernate : Error: java.math.BigInteger cannot be cast to java.math.BigDecimal

2018-02-13 Thread Francisco Olarte
Vinodh:

You are BOTTOM QUOTING a message which has nothing to thank me from, I
was just trying to clarify a misunderstanding of your original
question.

On Tue, Feb 13, 2018 at 4:14 PM, Vinodh NV  wrote:
> Thanks for the update Francisco. I had one more query:
> In Oracle the syntax for calling a stored procedure is
>Session sess = (Session) entityManager.getDelegate();
> sess.createSQLQuery("{ call reset() }").executeUpdate();
>
> Can you please let me know if the below equivalent for postgres is correct?
>Session sess = (Session) entityManager.getDelegate();
> sess.createSQLQuery("select reset()");

Had you quoted the correct message you would have seen I told you I do
not know hibernate, so no idea whar a session, entityManaer or or
delegates are. I also haven't done anthing serious with Oracle in this
century. So, I cannot tell you much.

Which I do know is in classic postgres you normally call functions
this way, by selecting.

Francisco Olarte.



Re: Require assistance in Postgres + Hibernate : Error: java.math.BigInteger cannot be cast to java.math.BigDecimal

2018-02-13 Thread Vinodh NV
Thanks for the update Francisco. I had one more query:
In Oracle the syntax for calling a stored procedure is
   Session sess = (Session) entityManager.getDelegate();
sess.createSQLQuery("{ call reset() }").executeUpdate();

Can you please let me know if the below equivalent for postgres is correct?
   Session sess = (Session) entityManager.getDelegate();
sess.createSQLQuery("select reset()");

Regards,
Vinodh



On Tue, Feb 13, 2018 at 5:12 PM, Francisco Olarte 
wrote:

> On Tue, Feb 13, 2018 at 12:39 PM, rob stone  wrote:
> >> long count = ((BigDecimal)ic.get(“EB”)).longValue();
> ..
> > The method is documented as:-
> > public static BigDecimal valueOf(long val)
>
> His problem seems to be the opposit, he does not have the long value
> and wants it.
>
> Francisco Olarte.
>


Re: Require assistance in Postgres + Hibernate : Error: java.math.BigInteger cannot be cast to java.math.BigDecimal

2018-02-13 Thread Francisco Olarte
On Tue, Feb 13, 2018 at 12:39 PM, rob stone  wrote:
>> long count = ((BigDecimal)ic.get(“EB”)).longValue();
..
> The method is documented as:-
> public static BigDecimal valueOf(long val)

His problem seems to be the opposit, he does not have the long value
and wants it.

Francisco Olarte.



Re: Require assistance in Postgres + Hibernate : Error: java.math.BigInteger cannot be cast to java.math.BigDecimal

2018-02-13 Thread Francisco Olarte
Vinodh:

On Tue, Feb 13, 2018 at 9:58 AM, Vinodh NV  wrote:
> Require assistance on the below:
> Code snippet:
> Map ic;
> //Populate values for ic
> long count = ((BigDecimal)ic.get(“EB”)).longValue();
>
>
> Getting the below error:
> java.math.BigInteger cannot be cast to java.math.BigDecimal
> ®java.lang.ClassCastException: java.math.BigInteger cannot be cast to
> java.math.BigDecimal
>
> Since this is not part of a query doing select cast (EB as bigint) will not
> help in this case:

I do not know hibernate, so Ihaven't the sligstest idea of why
get("EB") returns BigInteger or why you do not cast it to BigInteger
instead of BigDecimal.

But if your problem is it sometimes has Bigdecimal and sometimes
BigInteger you could try casting it to the parent, Number, which is
the one specifying longValue() and would make the code work with both.



Francisco Olarte.