I had an entity with variable created
type Date
public class UserEntity {
...
@Basic(optional = false)
@Column(name = "created", nullable = false, updatable = false)
@CreatedDate
private Date created;
...
}
the table created a column with the type TIMESTAMP
and correctly added the object to the table
[EL Fine]: sql: 2018-05-02 21:54:25.578--ClientSession(210949780)--Connection(1559972721)--INSERT INTO users (activation_token, avatar_id_in_cloud, avatar_provider, created, email, email_change_token, enabled, entity_version, modified_date, new_email, password, unique_id, username) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [null, null, null, [here created ==> 2018-05-02 21:54:25.279 <== here created, TkM2Gs9Hrd@gmail.com, null, true, 1, B@6f8060ac, null, $2a$12$/MwdBoXwBgHlxnsicVW.w.UWdYo6ulLH87aZtSxhdbBYA.9QacUXy, 74a45e29-c1f8-40dc-ac25-a7196d7870b4, JonkiPro]
however, according to Java 8, I changed the Date
type to Instant
.
public class UserEntity {
{
@Basic(optional = false)
@Column(name = "created", nullable = false, updatable = false)
@CreatedDate
private Instant created;
...
}
Now it automatically creates a table with a LONGVARBINARY
created column, the generated command looks like this
[EL Fine]: sql: 2018-05-02 21:54:25.578--ClientSession(210949780)--Connection(1559972721)--INSERT INTO users (activation_token, avatar_id_in_cloud, avatar_provider, created, email, email_change_token, enabled, entity_version, modified_date, new_email, password, unique_id, username) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [null, null, null, [here created ==> B@6f8060ac <== here created, TkM2Gs9Hrd@gmail.com, null, true, 1, B@6f8060ac, null, $2a$12$/MwdBoXwBgHlxnsicVW.w.UWdYo6ulLH87aZtSxhdbBYA.9QacUXy, 74a45e29-c1f8-40dc-ac25-a7196d7870b4, JonkiPro]
instead of the date there is a string B@6f8060ac
, and in the database it is already written as aced00057372000d6a6176612e74696d652e536572955d84ba1b2248b20c00007870770d02000000005aea177110a133c078
. What is happening with the date? I'm using the H2 base and EclipseLink.