How can I limit the number of columns being fetched by ActiveJDBC? Is there something similar to Hibernate Projections in ActiveJDBC?
How can I limit the number of columns being fetched by ActiveJDBC? Is there something similar to Hibernate Projections in ActiveJDBC?
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
andlast_name
attributes. In general, you can pass any query to thefindBySql()
, and the model will read values whose names match that model's attribute names.