Page 1 of 1
About Question enthuware.oce-jpad.v6.1.433 :
Posted: Tue Jan 10, 2012 2:25 pm
by PedroKowalski
Howdy,
In this answer:
Code: Select all
@ElementCollection
@CollectionTable(name="EMP_PROJECTS")
@Column(name="STARTDATE")
private Map<Project, Date> currentProjects;
don't we need to put @Temporal annotation, as the value of the map is a Date which must have defined temporal type?
Cheers!
Re: About Question enthuware.oce-jpad.v6.1.433 :
Posted: Sun Jan 15, 2012 2:13 pm
by MZ
PedroKowalski wrote:Howdy,
In this answer:
Code: Select all
@ElementCollection
@CollectionTable(name="EMP_PROJECTS")
@Column(name="STARTDATE")
private Map<Project, Date> currentProjects;
don't we need to put @Temporal annotation, as the value of the map is a Date which must have defined temporal type?
Cheers!
@Temporal is needed with java.util.Date, and not needed with java.sql.Date
Re: About Question enthuware.oce-jpad.v6.1.433 :
Posted: Fri May 25, 2012 2:39 pm
by cosminvacaroiu
Well everybody in this world when they see Date they think java.util.Date
So this question is misleading.
Re: About Question enthuware.oce-jpad.v6.1.433 :
Posted: Sat May 26, 2012 9:34 am
by admin
There are 2 points:
1. The answer to this question doesn't depend on whether there is @Temporal annotation present or not. Both - with and without @Temporal, are fine.
2. Whenever you retrieve a date from the DB using JDBC, you get java.sql.Date. So whenever I see a date in context of a DB, I think java.sql.Date. But again, what I think is irrelevant because that is not the point in this question. It doesn't matter here. Not specifying @Temporal doesn't necessarily make the option incorrect.
HTH,
Paul.