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 9015547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:46:35+00:00 2026-06-16T03:46:35+00:00

I am using a Derby database with Anorm in Play 2.0.2. Even though no

  • 0

I am using a Derby database with Anorm in Play 2.0.2. Even though no column has a BigDecimal field, I get the following error when inserting into a table.

Execution exception [[RuntimeException: TypeDoesNotMatch(Cannot convert 1:class java.math.BigDecimal to Long for column .1)]]

If I look in the table, I can see that my data has been entered so I infer that the problem has to do with returning the new key. But I clearly declare the key as a bigint–why the complaint about BigDecimal?

  • 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-16T03:46:36+00:00Added an answer on June 16, 2026 at 3:46 am

    It turns out that Derby always returns the key as a BigDecimal–even if they key is defined otherwise. The solution is to use a custom ResultSetParser to handle the BigDecimal. The id column returned is named “1”.

      def idResultSetParser(implicit extractor: anorm.Column[java.math.BigDecimal]) =
        ResultSetParser.singleOpt[java.math.BigDecimal](
          anorm.SqlParser.get[java.math.BigDecimal]("1"))
    

    Or, putting it all together.

      import java.math.BigDecimal
      s.executeInsert[Option[BigDecimal]](
          ResultSetParser.singleOpt[BigDecimal](
              anorm.SqlParser.get[BigDecimal]("1")))
    

    You can then map it to a Long with map (_.longValue).

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

Sidebar

Related Questions

I have a Java app that has an embedded Derby database (no hibernate though).
I'm using derby as an embedded database. Furthermore, I'm using it's in-memory database option
I want to work with a file-based database using apache derby. I was wondering
Using the embedded driver I can connect to my derby database using the JDBC
Please have a look at the following code. I am using Apache Derby as
I am using embedded Apache Derby database for JUnit tests. I have some JPA
I have been developing a Java application using J2EE and a Derby database. My
I would like to create an in-memory database for testing purposes using Derby/JavaDB. I
I have (java) code that creates and populates tables in a derby database, using
I have created a JavaDB(Derby) database using Netbeans 7.1 on my mac and I

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.