A small detail when creating an Oracle table will cause you to handle the Java Type conversion it's time for the egg to hurt.

Source: Internet
Author: User

1, before the project, the database was designed with PowerDesigner, because at the time of the design did not notice, the type of int did not give length

When you build the database, Oracle defaults to the type that you generate, which is a large type of bigdecimal. I felt nothing at the time. In the background, the new one bigdecimal out and then it's saved.

But then a colleague in the statistical data record, COUNT (*) Statistics is also bigdecimal this time with hibernate turn very troublesome

If it is of type int then hibernate goes in the way:

int count = ((Long) createquery (HQL). Uniqueresult ()). Invalue ()

But if it's the one I made a small mistake on,

That's how it should turn out:

BigDecimal b=new BigDecimal ((Long) createquery (HQL). Uniqueresult ()). Invalue ());

int I=b.intvalue ();

At this point i is the int type, before because the type of bigdecimal has not been processed. Although help him to solve, but do not know there is no easy way, if you have a point of view

A small detail when creating an Oracle table will cause you to handle the Java Type conversion it's time for the egg to hurt.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.