Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: JPA TIMESTAMP (MySQL)

  1. #1
    Member
    Join Date
    Sep 2011
    Posts
    63
    My Mood
    Confused
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default JPA TIMESTAMP (MySQL)

    I have a TIMESTAMP Columns in my MySQL database. This is the relevant section of the entity class:

    @Basic(optional = false)
    @NotNull
    @Column(name = "created_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;

    My problem is that it updates to a new TIMESTAMP automatically every time I persist anything to that row in the database. I am explicitly NOT updating that value but it updates itself. How do I prevent that from happening so it simply retains the original value entered?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JPA TIMESTAMP (MySQL)

    Make sure the column value is not automatically created. How did you create the table? Does the date field have a default value that specifies the current time?

  3. #3
    Member
    Join Date
    Sep 2011
    Posts
    63
    My Mood
    Confused
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: JPA TIMESTAMP (MySQL)

    I created the table using workbench, I can't see anything that denotes that the value should be automatically created, what should I be looking for? With regards to specifying the current time the answer is no. I am simply creating a new Date() when the user is created and it seems to automatically add in the time.

Similar Threads

  1. MySQL
    By Vagelism22678 in forum JDBC & Databases
    Replies: 2
    Last Post: March 6th, 2012, 10:15 AM
  2. JDBC+MYSQL
    By maya700 in forum JDBC & Databases
    Replies: 1
    Last Post: September 19th, 2011, 02:30 PM
  3. Input Timestamp in JSP
    By jai in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: February 28th, 2011, 10:26 AM
  4. Java.jar and Mysql.jar
    By kurt-hardy in forum Java Theory & Questions
    Replies: 1
    Last Post: January 27th, 2011, 09:48 AM
  5. How to get unix timestamp from formatted date?
    By snytkine in forum Java Theory & Questions
    Replies: 5
    Last Post: October 12th, 2010, 08:07 AM

Tags for this Thread