Is there a way to map a legacy column to a different name with ActiveJDBC? My use case involves a legacy database - I have date_created and last_updated which I'd like to be used as the created_at and updated_at columns so they get auto populated, but I'm not seeing a way to do this in the documentation. I think it'd be rather handy to have an annotation based way to map all columns (especially for those of us who like to use camelCase on the web side and underscores in our column names).
Asked
Active
Viewed 126 times
1 Answers
2
The names of these columns are kind of hard-coded in ActiveJDBC. There are a couple of solutions though:
- Create an updatable view in the database to satisfy the framework
- Implement this feature using ActiveJDBC lifecycle callbacks: http://javalite.io/lifecycle_callbacks
If you chose the #2, you can manage these in the beforeSave()
method by setting your attributes date_created
and last_updated
UPDATE: If you chose #2, be sure to overview ActiveJDBC Inheritance.

ipolevoy
- 5,432
- 2
- 31
- 46
-
#2 - nice - did not think of that one, but that'll do. I might try putting that in my abstract base class - hopefully that'll work. – Todd Sharp Apr 21 '17 at 15:59
-
yep, abstract class is where I'd put this in. – ipolevoy Apr 21 '17 at 16:02
-
added a link to inheritance – ipolevoy Apr 21 '17 at 16:03