문제

I have an Entity with a TIMESTAMP column. When I use an EntityManager to persist a new entry in my database, I can see the new row correctly set in my table but if I try to retrieve this Entity with a preparedQuery, I get back an Entity with the TIMESTAMP attribute Null, whereas it is not null in the table.

@Basic(optional =     false)
@NotNull
@Column(name = "devis_date_crea", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date devisDateCrea;

NB: until I set the validation mod to null in the persistence context the persist method threw an EJBCallBackException.

도움이 되었습니까?

해결책

I'm not sure if you know, but SQL Timestamp actually doesn't contains any time or date.

Timestamp is a data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database. timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.

If you need datetime, you should use datetime type. if you need it to change with every create and update, you can use default value for creation and trigger for update.

more info http://msdn.microsoft.com/en-us/library/aa260631(v=sql.80).aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top