Having Diffyerent data types in the DB and DTO in Hibernate
posted 8 years ago
in my database, i m storing a date property as a Date object and in my DTO i m storing the property as an instance field of type Date. but in my getDate method i m returning a long ( date.getTime()). and i keep getting a classCastException when testing this code.
Is it possible to have the type in the getters and setters different than the type of the instance fields, or to have the date in the DB as a Date, then in the mapping having it as a long?
Why do you need to do this? A Date object has a method on it to get a long value, any reason you don't just use this?
if it is up to me i would just keep everything as date and just use the GetTime when i need a long, but the project description says that the date in the DB should be Date and in the DTO should be long.
Thanks for your response
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads