-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: TemporalType.TIME with Oracle
PostPosted: Wed Apr 20, 2011 12:49 pm 
Newbie

Joined: Wed Apr 20, 2011 12:05 pm
Posts: 1
I've a JPA 2.0 entity, with a java.util.Date field mapped to a DATE column in Oracle. The field intended to represent just the time part, so I added the @Temporal(TemporalType.TIME) annotation.
I'm using JBoss AS 6.0.0.

All is fine when I read the entity because the field contains a java.sql.Time instance.

Insteand when I persist the entity to the DB I can insert a value containing also a date part and it's written to the DB.

I was expecting that the date part was stripped away from the value written to the DB or that a validation would throw an exception, but this isn't the case.

The think get worse when the Date field is in the key (and this is my case) because if I try to remove the entity nothing happens. For example:

Code:
Date key = new Date(); // Date and time
MyEntity ent = new MyEntity();
ent.setTime(key);
ent.set....;
em.persist(ent); // Date and time written in the DB column
em.flush();
em.clear();

ent = query.getSingleResult(); // a query loading the entity persisted above
System.out.println(em.getTime()); // Just the time part
em.remove(ent);
// The row is still in the db


I think this happens because the DELETE statement use just the time part in the condition.

Is this the right behaviour according to the specification? Have I to validate the value manually before setting it into my entity the entity?

Thanks,
Andrea


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.