Which is best practice?
@Column(name = "FOO", columnDefinition = "TIMESTAMP")
private Date foo;
Or
@Column(name = "FOO")
@Temporal(TemporalType.TIMESTAMP)
private Date foo;
The documentation suggests that using columnDefinition is non-portable …
That’s true.
columnDefinitionspecified the SQL data type that will be used. This data type may however not be available in all RDBMS. In JPA, it’s the JPA provider’s duty to figure out what SQL works on what DB. You can specifiy part of that configuration, but you will always risk breaking support for some databases.@Temporalon the other hand is an abstraction that is part of the JPA standard. Every JPA provider must be able to map the different types of@Temporalto different SQL types for all supported databases.