Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:48:39+00:00 2026-06-09T09:48:39+00:00

We are generating our jpa access layers with MyEclipse. Afterwards we have the generated

  • 0

We are generating our jpa access layers with MyEclipse. Afterwards we have the generated models and data layer access services. We ran into some problems for some fields with a defined precision.

Entity:

@Entity
public class TestEntity{
   @Column(name="DECTEST", scale = 3, precision = 13)
   BigDecimal decTest;

}

Now we create a bean and try to save it:

TestEntity te = new TestEntity();
te.setDecTest(new BigDecimal(1.2));

TestEntityService.save(te);

We get the following error:
Caused by: com.ibm.db2.jcc.c.SqlException: [ibm][db2][jcc][t4][1037][11190] Exception occurred during BigDecimal conversion. See attached Throwable for details.

Caused by: com.ibm.db2.jcc.a.a: [ibm][db2][jcc][converters][608][10994] Overflow occurred during numeric data type conversion of "1.1999999999999999555910790149937383830547332763671875".
at com.ibm.db2.jcc.a.e.a(e.java:61)
at com.ibm.db2.jcc.b.jb.a(jb.java:1772)
... 73 more

The problem seems to be that our BigDecimals scale is higher then the one from the database.

A working workaround is:

TestEntity te = new TestEntity();

BigDecimal decTest = new BigDecimal(1.2);

te.setDecTest(decTest.setScale(3,RoundingMode.HALF_UP);

TestEntityService.save(te);

With this workaround we reduce the BigDecimals precicsion manually to the one of the database.

However if the data model changes we would have to adjust the scale there manually. Is there a way to get our jpa / hibernate implementation to do that conversion for us automatically? E.g. with setting a property. Doing it at the spot where one is creating the bean would be the wrong spot to do it anyways.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:48:41+00:00Added an answer on June 9, 2026 at 9:48 am

    You could use a custom user type, or you could simply implement the setter of the property like this:

    public void setDecTest(BigDecimal decTest) {
        this.decTest = decTest.setScale(3, RoundingMode.HALF_UP));
    }
    

    This rounding would thus be encapsulated in the entity.

    Note that using a double to initialize a BigDecimal is a bit strange. If you want 1.2 to be stored in the BigDecimal, use new BigDecimal("1.2"), and you won’t have a BigDecimal initialized with 1.1999999999999999555910790149937383830547332763671875.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are a lead generating company and have developed one application where our customers
There is some code in our system for automatically generating self-signed certificates into a
I am generating a table and inserting the data into that table. The table
We have a database that persist our metadata and data. Our metadata is produced
It's a third party application generating huge amounts of log entries on our app
Generating normal columnar data in excel file is quite easy but does any one
when generating python wrappers with swig the python wrapper classes in the generated python
When generating models from postgresql with ColdFusion Illudium Code generator the boolean values get
We're using hibernate entitymanager to map our entities through JPA. And we are using
At some point our WebLogic's Portal web project in Workshop stopped generating the WEB-INF/classes/_pageflow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.