0

Let's say I have a column to store the creation time of the record, like a timestamp with DEFAULT CURRENT_TIMESTAMP. After inserting, the Model doesn't contain the value set by the database (the value is null).
Is the only way to get such info to execute myself an extra SELECT query after saving?

Thanks.

Maxime Laval
  • 4,068
  • 8
  • 40
  • 60

1 Answers1

0

According to this page of documentation: http://javalite.io/autogenerated_fields you can create two columns: created_at and updated_at.

Data in these columns will be automatically maintained by the framework. If the column value is NULL, then the respective attribute value will also be null

ipolevoy
  • 5,432
  • 2
  • 31
  • 46
  • I guess my question was more "in general", for instance it could be a boolean field with a default value. Anyway I ended up doing ```this.refresh()``` in the ```afterSave()``` method. – Maxime Laval Dec 28 '15 at 22:41
  • doing refresh after save makes no sense. It will also generate another call to DB. If you have the attribute values in the model, they are saved and still present in the model. If you need a default value, write a custom getter and return you default value if nothing came from DB. – ipolevoy Dec 29 '15 at 09:30