The field in the java class looked like this :
private LocalDateTime updateTime;
However, Hibernate stores it in the database like this:
(output of "select update_time from my_table;")
ac ed 00 05 73 72 00 1b 6f 72 67 2e 6a 6f 64 61 2e 74 69 6d 65 2e 4c 6f 63 61 6c 44 61 74 65 54 69 6d 65 fc 45 53 6c f5 a5 87 10 02 00 02 4a 00 0c 69 4c 6f 63 61 6c 4d 69 6c 6c 69 73 4c 00 0b 69 43 68 72 6f 6e 6f 6c 6f 67 79 74 00 1a 4c 6f 72 67 2f 6a 6f 64 61 2f 74 69 6d 65 2f 43 68 72 6f 6e 6f 6c 6f 67 79 3b 78 70 00 00 01 42 09 8e 35 21 73 72 00 27 6f 72 67 2e 6a 6f 64 61 2e 74 69 6d 65 2e 63 68 72 6f 6e 6f 2e 49 53 4f 43 68 72 6f 6e 6f 6c 6f 67 79 24 53 74 75 62 a9 c8 11 66 71 37 50 27 03 00 00 78 70 73 72 00 1f 6f 72 67 2e 6a 6f 64 61 2e 74 69 6d 65 2e 44 61 74 65 54 69 6d 65 5a 6f 6e 65 24 53 74 75 62 a6 2f 01 9a 7c 32 1a e3 03 00 00 78 70 77 05 00 03 55 54 43 78 78
Now we decided to change the java code to look like:
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
private LocalDateTime updateTime;
So that the value in the database looks like
(output of "select update_time from my_table;")
2013-12-18 00:00:00.0
However, the database table already has some values in this column. How can we now convert the datatype of update_time to timestamp so that the existing values are also correctly handled?
The database version and dependencies used are as below: database version:
psql --version
psql (EnterpriseDB) 9.1.6.10
mvn dependencies for hibernate:
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.1.Final</version>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.0.1.Final</version>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>1.2.0.Final</version>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
Really stuck here. Any idea how can this be achieved? Any help here is truly appreciated.