I migrated mysql version from 5.5.40 to 8.0.18. After migration, I changed By JBoss 6 datasource configuration for driver class.
<driver-class>com.mysql.cj.jdbc.Driver</driver-class>
I have put mysql-connector-java-8.0.18 to lib folder. Then my applications is deployed to Jboss 6 without problem. When I start to test application, I have found something. Regarding to Simulation Job entity, I set startDateTime column a date. After simulation job is saved to database, startDateTime is different from one which I set. But there is only one second difference. For example İf I set date to 2019-11-08 15:20:12, Database stores it 2019-11-08 15:20:13. I am not sure this is related to timezone. But anyway I changed time zone of mysql using following statement.
SET GLOBAL time_zone = '+3:00';
@Entity
@Table(name = "SIMULATION_JOB")
public class SimulationJob implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1768265008703114922L;
public SimulationJob() {
super();
}
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "SimulationJobIdGen")
@Column(name = "ID")
private long id;
@Column(name = "NAME")
@NotNull
@Size(max = 50)
private String name;
@Column(name = "PRIORITY")
private int priority;
@ManyToOne
@JoinColumn(name = "OWNER_USER_ID")
private User ownerUser;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATETIME")
private Date createDateTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "START_DATETIME")
private Date startDateTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "END_DATETIME")
private Date endDateTime;
}
I guess it may have to do with rounding of timestamp. Before MySQL 5.6.4 the handling of fractional seconds (i.e. milliseconds) was different.
See also:
https://dev.mysql.com/doc/refman/8.0/en/fractional-seconds.html
https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html