List Info

Thread: Timestamp and @Temporal




Timestamp and @Temporal
user name
2007-10-21 18:08:18
The following link shows you can place Temporal annotation on a java.sql.Timestamp

http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#Temporal


But the following code generates error on deployment in Glassfish v2:

Column(name = "createDateTime", nullable = false)
Temporal(value = TemporalType.TIMESTAMP)
private java.sql.Timestamp createdDateTime;

The error message:

"Exception Description: The type [class java.sql.Timestamp] for the attribute [createdDateTime] on the entity class [class brazos.permit.ejb.domain.User] is not a valid type for a temporal mapping. The attribute must be defined as java.util.Date or java.util.Calendar."

Can someone confirm if this is a bug or if I'm overlooking something?
Thanks
-sud



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Timestamp and @Temporal
user name
2007-10-21 18:59:44
Hi Sud,

On Oct 21, 2007, at 4:08 PM, sud wrote:

The following link shows you can place Temporal annotation on a java.sql.Timestamp

http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#Temporal

This link says "for persistent fields or properties of type java.util.Date and java.util.Calendar only."

The way I read this is that there is no need for this annotation if the type of the persistent field is java.sql.Timestamp. 

For Date and Calendar, there are many database types the field could be mapped to. For java.sql.Timestamp, there's no ambiguity.

Try removing the Temporal annotation and see what happens.

Craig

But the following code generates error on deployment in Glassfish v2:

Column(name = "createDateTime", nullable = false)
Temporal(value = TemporalType.TIMESTAMP)
private java.sql.Timestamp createdDateTime;

The error message:

"Exception Description: The type [class java.sql.Timestamp] for the attribute [createdDateTime] on the entity class [class brazos.permit.ejb.domain.User] is not a valid type for a temporal mapping. The attribute must be defined as java.util.Date or java.util.Calendar."

Can someone confirm if this is a bug or if I'm overlooking something?
Thanks
-sud



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com

Craig Russell

Architect, Sun Java Enterprise System http://java.sun.com/products/jdo

408 276-5638 Craig.Russellsun.com">mailto:Craig.Russellsun.com

P.S. A good JDO? O, Gasp!


Re: Timestamp and @Temporal
user name
2007-10-24 09:42:18
Getting rid of the Temporal worked. So out of curiosity is
there a use
for  Temporal.TIMESTAMP?

-sud

Craig L Russell wrote:
> Hi Sud,
>
> On Oct 21, 2007, at 4:08 PM, sud wrote:
>
>> The following link shows you can place Temporal
annotation on a
>> java.sql.Timestamp
>>
>> http://
www.oracle.com/technology/products/ias/toplink/jpa/resources
/toplink-jpa-annotations.html#Temporal
>>
> This link says "for persistent fields or
properties of type
> java.util.Date and java.util.Calendar only."
>
> The way I read this is that there is no need for this
annotation if
> the type of the persistent field is java.sql.Timestamp.

>
> For Date and Calendar, there are many database types
the field could
> be mapped to. For java.sql.Timestamp, there's no
ambiguity.
>
> Try removing the Temporal annotation and see what happens.
>
> Craig
>>
>> But the following code generates error on
deployment in Glassfish v2:
>>
>> Column(name = "createDateTime", nullable =
false)
>> Temporal(value = TemporalType.TIMESTAMP)
>> private java.sql.Timestamp createdDateTime;
>>
>> The error message:
>>
>> "Exception Description: The type [class
java.sql.Timestamp] for the
>> attribute [createdDateTime] on the entity class
[class
>> brazos.permit.ejb.domain.User] is not a valid type
for a temporal
>> mapping. The attribute must be defined as
java.util.Date or
>> java.util.Calendar."
>>
>> Can someone confirm if this is a bug or if I'm
overlooking something?
>> Thanks
>> -sud
>>
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam? Yahoo! Mail has the best spam
protection around 
>> http://mail.yahoo.com
>
> Craig Russell
>
> Architect, Sun Java Enterprise System http://java.sun.com/
products/jdo
>
> 408 276-5638 mailto:Craig.Russellsun.com
>
> P.S. A good JDO? O, Gasp!
>
>

Re: Timestamp and @Temporal
user name
2007-10-24 12:20:39
Hi Sud,

On Oct 24, 2007, at 7:42 AM, sudhakar wrote:

> Getting rid of the Temporal worked. So out of
curiosity is there a  
> use
> for  Temporal.TIMESTAMP?

The problem that is solved by the annotation is what
database type to  
use for Date and Calendar fields in entities. If you use a
Date just  
to store day information, you don't want to use a DATETIME
column in  
the database. But if you store milliseconds in your Date
field, you  
want the DATETIME column to avoid losing information.

So if you store time information in your Date or Calendar,
you would  
use the Temporal.TIMESTAMP value.

Regards,

Craig
>
> -sud
>
> Craig L Russell wrote:
>> Hi Sud,
>>
>> On Oct 21, 2007, at 4:08 PM, sud wrote:
>>
>>> The following link shows you can place Temporal
annotation on a
>>> java.sql.Timestamp
>>>
>>> http://www.oracle.com/technology/products/ias/toplink/
jpa/ 
>>>
resources/toplink-jpa-annotations.html#Temporal
>>>
>> This link says "for persistent fields or
properties of type
>> java.util.Date and java.util.Calendar only."
>>
>> The way I read this is that there is no need for
this annotation if
>> the type of the persistent field is
java.sql.Timestamp.
>>
>> For Date and Calendar, there are many database
types the field could
>> be mapped to. For java.sql.Timestamp, there's no
ambiguity.
>>
>> Try removing the Temporal annotation and see
what happens.
>>
>> Craig
>>>
>>> But the following code generates error on
deployment in Glassfish  
>>> v2:
>>>
>>> Column(name = "createDateTime",
nullable = false)
>>> Temporal(value = TemporalType.TIMESTAMP)
>>> private java.sql.Timestamp createdDateTime;
>>>
>>> The error message:
>>>
>>> "Exception Description: The type [class
java.sql.Timestamp] for the
>>> attribute [createdDateTime] on the entity class
[class
>>> brazos.permit.ejb.domain.User] is not a valid
type for a temporal
>>> mapping. The attribute must be defined as
java.util.Date or
>>> java.util.Calendar."
>>>
>>> Can someone confirm if this is a bug or if I'm
overlooking  
>>> something?
>>> Thanks
>>> -sud
>>>
>>>
>>>
>>>
__________________________________________________
>>> Do You Yahoo!?
>>> Tired of spam? Yahoo! Mail has the best spam
protection around
>>> http://mail.yahoo.com
>>
>> Craig Russell
>>
>> Architect, Sun Java Enterprise System http://java.sun.com/pro
ducts/ 
>> jdo
>>
>> 408 276-5638 mailto:Craig.Russellsun.com
>>
>> P.S. A good JDO? O, Gasp!
>>
>>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/
products/jdo
408 276-5638 mailto:Craig.Russellsun.com
P.S. A good JDO? O, Gasp!

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )