About Question enthuware.oce-jpad.v6.1.433 :

Moderator: admin

Post Reply
PedroKowalski
Posts: 25
Joined: Thu Aug 04, 2011 10:36 am
Contact:

About Question enthuware.oce-jpad.v6.1.433 :

Post 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!

MZ

Re: About Question enthuware.oce-jpad.v6.1.433 :

Post 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

cosminvacaroiu

Re: About Question enthuware.oce-jpad.v6.1.433 :

Post by cosminvacaroiu »

Well everybody in this world when they see Date they think java.util.Date
So this question is misleading.

admin
Site Admin
Posts: 10385
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.1.433 :

Post 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests