How can I limit the number of columns being fetched by ActiveJDBC? Is there something similar to Hibernate Projections in ActiveJDBC?
Asked
Active
Viewed 248 times
1 Answers
1
Technically speaking, ActiveJDBC is an ORM, and as such will fetch all attributes related to a model (all columns from table). If a model instance is does not have them all, than the 'O' is missing from the ORM :). In other words, it stops being an object that represents a relation.
If this is absolutely what you need to do, then you can do the following:
List<Person> retirees = Person.findBySql("select first_name, last_name from people where age > ? ", 65);
This way, the query will populate only the first_name
and last_name
attributes. In general, you can pass any query to the findBySql()
, and the model will read values whose names match that model's attribute names.

ipolevoy
- 5,432
- 2
- 31
- 46