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

  • SEARCH
  • Home
  • 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 7909675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:32:34+00:00 2026-06-03T12:32:34+00:00

In our business logic we have to handle positive and negative Double.Infinity values as

  • 0

In our business logic we have to handle positive and negative Double.Infinity values as well as Double.NaN values.

We have to store these values into Microsot SQL Server 2008 database. The problem is that Microsot SQL Server doesn’t support infinity or nan values. (Problem description for SQL Server 2005, also applicable for MS SQL Server 2008).

We are using Hibernate 3.6.7 as our JPA implementation and Microsoft’s sqljdbc4 driver version 4.0.2206.100.

We have tried to solve this issue by setting JPA entity’s column definition to VARCHAR like this

@Column(columnDefinition = "VARCHAR(40)")
private Double foo;

This does not seem to have any effect, even though column definition is properly changed to VARCHAR in the database. It seems that the infinity value is caught in JDBC driver’s validation since we get the following stacktrace when trying to INSERT Double.Infinity value:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The incoming tabular data  stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 6 (""): The supplied value is not a valid instance of data type float. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:314)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
    at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
    ... 79 more

Any ideas how to work around this issue are welcome.

  • 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-03T12:32:37+00:00Added an answer on June 3, 2026 at 12:32 pm

    Here’s a simple workaround for this issue:
    Use String for field type and do the conversion in getters and setters.
    This way you don’t have to change your business logic and the actual transformation logic is encapsulated nicely.

    // Column definition is not a necessity here
    @Column(columnDefinition = "VARCHAR(40)")
    private String foo;
    
    public Double getFoo() {
        return this.foo != null ? Double.valueOf(this.foo) : null;
    }
    
    public void setFoo(Double d) {
        this.foo = d != null ? d.toString() : null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So we have recently moved much of our business logic into a service layer,
In our case we have some business logic that looks into several tables in
Our current project has ran into a circular dependency issue. Our business logic assembly
We have a lot of our business logic in an oracle database. So we
We usually put unnecessary checks in our business logic to avoid failures. Eg. 1.
We are building an ASP.NET project, and encapsulating all of our business logic in
Our business deals with houses and over the years we have created several business
Our business currently has an online store and recently we've been offering free specials
We have problem with our Qt based production server for our business application. When
Generally We have some business logic that is causing a bottle neck within a

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.