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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:54:26+00:00 2026-06-15T23:54:26+00:00

I have a Spring / Hibernate project and I am trying to store a

  • 0

I have a Spring / Hibernate project and I am trying to store a date into the database but it’s not working. It must be something stupid but I have no idea what I am doing wrong.

Here is my code:

user.setFailedPasswordAnswerAttemptCount(0);
user.setLastLoginDate(new Date());
user.setIsOnline(true);

The other two variables (failedPasswordAnswerAttemptCount and isOnline) are getting written to the database without issue. I have also tried it with just passing a java.util.Date instead of a java.sql.Timestamp…same result. Here is how the property is defined on the user object:

private Date lastLoginDate;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="last_login_date")
public Date getLastLoginDate() {
    return this.lastLoginDate;
}

public void setLastLoginDate(Date lastLoginDate) {
    this.lastLoginDate = lastLoginDate;
}

Here is the column definition:

`last_login_date` datetime DEFAULT NULL

Any help? I don’t even know what else to look for as this should be working.

Some more detail about the error: No errors or strange messages in the hibernate log. The hibernate log is showing a parameterized query but it isn’t telling me what it is actually writing. It looks like it’s not updating the column at all. In other words, if there is already a date there it doesn’t change, or if it is null it doesn’t change.

Update: I have looked at the logs and it looks like hibernate does write the proper data, but then immediately writes the incorrect data again. I see the following entry in the log:

11:15:12.280 [http-bio-8080-exec-26] TRACE o.h.e.def.AbstractSaveEventListener - detached instance of: com.hi.model.User
11:15:12.280 [http-bio-8080-exec-26] TRACE o.h.e.def.DefaultMergeEventListener - merging detached instance

And right after that I see it putting the old value back in for the lastLoginDate.

  • 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-15T23:54:27+00:00Added an answer on June 15, 2026 at 11:54 pm

    I found the problem. I am refactoring some code and it looks like I was doing this:

    //get user object
    User user = getUser();
    //call a function which modifies user
    functionModifiesUser();
    //modify user
    user.blah = blah;
    entityManager.merge(user);
    

    So the parent function had a stale copy of the user object when I tried to save it. Actually, removing the merge statement was enough to fix it. But I have refactored the code to put all this in one place.

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

Sidebar

Related Questions

I'm trying to build a spring roo project using hibernate and an oracle database.
I have Spring MVC project. I am using HSQL database and Hibernate. I have
I have Maven project with Hibernate and Spring framework. I want Hibernate to create
I have a project with spring and hibernate in GWT, I am using below
I have a spring mvc project and am trying to test out a rest
I have a project coded using Spring-hibernate-activeMq What I would like to know is
While working on a Spring 3 MVC project using Hibernate, we encountered an annoying
I have a Spring Roo + Hibernate project which takes a JTS well-known text
I have Spring MVC application integrated with Hibernate. I'm trying to log jdbc SQL
I am trying to get a project that I had working in Spring 3.1

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.