facebook

JPA/DAO update bug with MySQL

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse Archived
  2.  > 
  3. Bugs
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #286541 Reply

    DougMH
    Participant

    I think I’ve found a bug in JPA/DAO

    I’m trying to update a MySQL DATETIME field after some computations

    dReturn below = Mon Jun 30 16:28:59 EDT 2008

    String dReturn = mySched.getLastRun().toString();
    switch(mySched.getScheduleId()) {
    case 1: DatabaseCount(); break;
    case 2: DatabaseContent(); break;
    case 3: FileCount(saSizeDirectory); break;
    case 4: FileContent(saContentDirectory); break;
    default: System.out.println(“No reports to run”);
    }
    TransactionStatus status = txManager
    .getTransaction(new DefaultTransactionDefinition());
    dao.update(mySched);
    txManager.commit(status);

    So, at the time of update mySched.getLastRun() has a full date time in it, but when I update the MySQL database, the time is going in as…

    2008-06-30 00:00:00

    … updated to the correct yyyy-mm-dd, but the time is always 00:00:00

    Is the a dao bug? A MySQL bug? Am I doing something wrong? My setter/getter as generated by the reverse engineering is


    @Temporal
    (TemporalType.DATE)
    @Column(name = “last_run”, nullable = false, length = 0)
    public Date getLastRun() {
    return this.lastRun;
    }

    public void setLastRun(Date lastRun) {
    this.lastRun = lastRun;
    }

    #286543

    DougMH
    Participant

    BTW, When I update MySQL using straight JDBC, it works just fine

    public void UpdateLastRun(ArrayList<Integer> intList) {
    try {
    Connection con = getConnection();
    String sqlString = “”;
    Statement stmt = null;
    for (int i=0 ; i < intList.size() ; i++){
    sqlString = ” update monitor_schedule” +
    ” set last_run = current_date()” +
    ” where schedule_id = ” + intList.get(i);
    stmt = con.createStatement();
    stmt.executeUpdate(sqlString);
    }
    stmt.close();
    con.close();
    } catch (Exception e) {
    System.out.println(e.getMessage());
    }

    }

    #286545

    DougMH
    Participant

    Also, FYI, in the MySQL

    last_run = DATETIME

    #286595

    Loyal Water
    Member
Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: JPA/DAO update bug with MySQL

You must be logged in to post in the forum log in