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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:15:06+00:00 2026-05-30T19:15:06+00:00

I wrote a simple class: @Entity @Table(name = battle_log) @SQLInsert(sql = INSERT INTO battle_log

  • 0

I wrote a simple class:

@Entity
@Table(name = "battle_log")
@SQLInsert(sql = "INSERT INTO battle_log (id, version, date_created, some_date) VALUES (?,?,?,?)", check = ResultCheckStyle.NONE)
@NamedQueries(value = {
        @NamedQuery(name = "BattleLog.findAll",
                query = "SELECT a FROM BattleLog a"),
        @NamedQuery(name = "BattleLog.findAllBySomeDate",
                query = "SELECT a FROM BattleLog a WHERE a.someDate = :someDate")
})
public class BattleLog implements Serializable {
    private Long id;
    private Integer version;

    private Date someDate;
    private Date created;

    public BattleLog() {
        created = new Date();
    }

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Version
    @Column(name = "version")
    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @Column(name = "date_created", nullable = false, columnDefinition = "timestamp")
    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    @Column(name = "some_date", columnDefinition = "timestamp")
    public Date getSomeDate() {
        return someDate;
    }

    public void setSomeDate(Date someDate) {
        this.someDate = someDate;
    }

}

And a simple Bootstrap.groovy

    BattleLog blog = new BattleLog(someDate: new Date())
    blog.save()

    println("should be saved now")

I’m doing it as a test project to see how Grails and Postgres partitioning work together.
Everything is fine, if I comment out @SQLInsert code. When I do have it, I’m getting this exception:

Caused by: java.sql.SQLException: Wrong data type: java.lang.NumberFormatException: For input string: "2012-02-29 13:48:17.67"
    at org.hsqldb.jdbc.Util.throwError(Unknown Source)
    at org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source)
    at org.hsqldb.jdbc.jdbcPreparedStatement.setTimestamp(Unknown Source)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.setTimestamp(DelegatingPreparedStatement.java:147)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.setTimestamp(DelegatingPreparedStatement.java:147)
    ... 29 more

I’m not sure what can I do to make it work :/

Hope someone could help me.

Thanks,
Krystian

EDIT:

I’ve tried using JodaTime, and after a little fight with dependencies I got it to run, however got errors like the one above.
I’ve also reverted back to using java.util.Date and used @Temporal(TemporalType.DATE) and TIMESTAMP but got an error [for date, similar for timestamp but with the time part]:

Caused by: java.sql.SQLException: Wrong data type: java.lang.NumberFormatException: For input string: "2012-02-29"

I am quite sure I have to add something to the SQLInsert query, something that would convert string to a date. I can’t, however, find anything.

  • 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-05-30T19:15:07+00:00Added an answer on May 30, 2026 at 7:15 pm

    Uhhh…

    Everything because a dumb mistake.

    SQLInsert should look like:

    @SQLInsert(sql = "INSERT INTO battle_log (date_created, some_date, version) VALUES (?,?,?)", check = ResultCheckStyle.NONE)
    

    That’s without the ID column!!

    after removing it everything started to work just fine!

    EDIT:

    The above worked fine for HSQLDB. When I started to work with postgres I ended up again with some weird errors.
    In the end I had to add the ID, but… what’s most important..
    The ? ? ? ? values are added in the same order as the order in which they were created [in DDL statement].

    Also, here’s a link to a sample project where everything described is used:

    https://github.com/krstns/grailsPostgresPartitioning

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

Sidebar

Related Questions

I have a simple domain class Licensee: @Entity @Table(name = LICENSEE) @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
I wrote simple GUI page: public class Test01 { RootPanel r = RootPanel.get(); public
I wrote a simple program that using Class::ArrayObjects but It did not work as
I wrote simple class in JS witch works, but i had problem when i
I wrote this simple class that provides buffering for general output operation: template <typename
I'm new to entity frame work code first. I have simple class called Cat
I want to write a simple class (PHP5) that can 'run' an unknown amount
I've been trying to write a simple Static-class State Machine for my application to
I wrote simple load testing tool for testing performance of Java modules. One problem
I wrote a simple batch file as a PowerShell script, and I am getting

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.