2

I have a table in my db with following fields

field1 of type NUMBER(38)
other fields

field2 is of type NUMBER(38)

Now i have some DAOS which provide me this fileld1 information in form of Object

 Object field1Value

Now i need to typecase it to a dataType.Which dataType it should be?In my case it is Integer
But why is it getting mapped to Integer, why not Long or BigDecimal ?
Integer is 32 bits but the field is NUMBER 38 in db

1 Answer 1

1

You shouldn't be casting anything. That's the role of the DAO - to effect a bridge between DB and app code.

You need to change the DAO to provide the appropriate datatype. BigInteger would be the best fit, because a long has only 64-bit precision, whereas Oracle's number(38) datatype has 126-bit precision, and your field has no decimal part.

Sign up to request clarification or add additional context in comments.

1 Comment

The thing is DAOS are already present.And it returns it in Object format.When i try to typecast it to BigInteger it gives exception saying cannot cast from Integer to BigDecimal.I know that DAOs should provide a concrete data type but its not the case here as i dont own it.Now the question is can i typecase it to integer .I thik there will be loss of precesion.I am sure that those are only integers and there are no decimal part

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.