Auto generating entities from a legacy database. Many of the tables have non standard date formats. All kinds of esoteric use of 开发者_如何学Cint fields... where one may contain century, year, month, day, hour, minute, second, some concatenated grouping there of and certain liberties taken with some columns in order to save a byte here or there.
Anyways there is no magic bullet in the conversion my question is that I think it makes the most sense to encapsulate each date with a Calendar type (implemented as a GregorianCalendar type). So I can have a consistent interface.
I should probably make the fields inaccessible so everything needs to be though the Calendar object. What issues would I need to take care of such that I could use my dates in queries?
You could add a delegate layer on top of your entities so that you expose this to your application. Eclipse will even help you generate these delegates (with some edits for date manipulation of course). The delegates then map the appropriate data to the entity so your database does not have to change. This will definitely help create a consistent date interface across your application. The down side is it adds extra code and another layer to you data persistence.
精彩评论