Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes casting varchar to Date/Calendar ? (DB table is readonly!) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "casting varchar to Date/Calendar ? (DB table is readonly!)" Watch "casting varchar to Date/Calendar ? (DB table is readonly!)" New topic
Author

casting varchar to Date/Calendar ? (DB table is readonly!)

Will Zelan
Ranch Hand

Joined: Apr 15, 2012
Posts: 56

I had to create entity-classes for db tables which already existed and which I can only read but not modify.

One problem with those tables is their bad design...
For example, one columns type is varchar but it contains a date formatted like this: "2012-08-08 14:23:48"

Now I need to do a query which checks, that this date is before another date (my parameter). This means I need hibernate to handle the varchar column as a Date, Timestamp, Calendar or whatever object which can be used in a query for comparisons.

Is there any way to handle a varchar-columns as ad "real" date? Using annotations, casts, ...?

Any help is appreciated!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: casting varchar to Date/Calendar ? (DB table is readonly!)
 
Similar Threads
java date format stored as varchar - need to convert it into date
problem related to timestamp
how to build a search engine?
How to access a calendar object(in db) through a jsp page?
I need a calendar with editable fields...