Thank you for the test case.
Here is a revised version that also prints the default time zone (and with some fixes and adjustments to the posting instructions):
import java.util.*;
import javax.persistence.*;
public class T707 {
public static void main(String[] args) {
EntityManagerFactory emf =
Persistence.createEntityManagerFactory(
"objectdb:$objectdb/db/test-my-entity.tmp;drop");
EntityManager em = emf.createEntityManager();
//()Create/persist
MyEntity e = new MyEntity();
em.getTransaction().begin();
em.persist(e);
em.getTransaction().commit();
System.out.println(e);
//()Refresh read back
em.refresh(e);
System.out.println(e);
//()Read back all
em.clear(); ///<<<clear local cache and read back new
Query query = em.createQuery("SELECT e FROM MyEntity e");
List resultList = query.getResultList();
System.out.println(resultList);
em.close();
emf.close();
System.out.println(TimeZone.getDefault());
}
@Entity
public static class MyEntity {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private long id;
String myname = "Roger";
java.sql.Time mytime =
new java.sql.Time(System.currentTimeMillis());
java.sql.Timestamp mytimestamp =
new java.sql.Timestamp(System.currentTimeMillis());
@Override
public String toString() {
return "MyEntity{" + "id=" + id + ", myname=" + myname +
", mytime=" + mytime + ", mytimestamp=" + mytimestamp + '}';
}
}
}
I ran it on my computer and the output looks correct:
MyEntity{id=1, myname=Roger, mytime=21:33:15, mytimestamp=2012-03-07 21:33:15.291}
MyEntity{id=1, myname=Roger, mytime=21:33:15, mytimestamp=2012-03-07 21:33:15.291}
[MyEntity{id=1, myname=Roger, mytime=21:33:15, mytimestamp=2012-03-07 21:33:15.291}]
sun.util.calendar.ZoneInfo[id="Asia/Jerusalem",offset=7200000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Asia/Jerusalem,offset=7200000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=26,startDayOfWeek=6,startTime=7200000,startTimeMode=0,endMode=1,endMonth=8,endDay=13,endDayOfWeek=0,endTime=7200000,endTimeMode=0]]
So as expected, this is probably related to specific settings. Maybe there is a problem when the time offset includes half a hour (e.g. UTC+05:30).
Could you please post the output that you get when you run the revised test?