|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javalite.activejdbc.AbstractLazyList<T>
org.javalite.activejdbc.LazyList<T>
org.javalite.activejdbc.SuperLazyList<T>
public class SuperLazyList<T extends Model>
The purpose of this class is to provide toMaps() method in cases of eager loading of dependencies.
This class is never used by application code directly, rather as a return value from Model.getAll(..)
methods.
| Field Summary |
|---|
| Fields inherited from class org.javalite.activejdbc.AbstractLazyList |
|---|
delegate |
| Constructor Summary | |
|---|---|
protected |
SuperLazyList()
|
| Method Summary | ||
|---|---|---|
boolean |
add(T o)
|
|
protected void |
hydrate()
|
|
|
include(Class<? extends Model>... classes)
This method includes associated objects. |
|
|
limit(long limit)
This method limits the number of results in the resultset. |
|
|
load()
This method exists to force immediate load from DB. |
|
|
offset(long offset)
This method sets an offset of a resultset. |
|
|
orderBy(String orderBy)
Use this method to order results by a column. |
|
| Methods inherited from class org.javalite.activejdbc.LazyList |
|---|
collect, collect, collectDistinct, collectDistinct, dump, dump, toJson, toMaps, toSql, toSql, toXml, toXml |
| Methods inherited from class org.javalite.activejdbc.AbstractLazyList |
|---|
add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected SuperLazyList()
| Method Detail |
|---|
public boolean add(T o)
add in interface Collection<T extends Model>add in interface List<T extends Model>add in class AbstractLazyList<T extends Model>protected void hydrate()
hydrate in class LazyList<T extends Model>public <E extends Model> LazyList<E> load()
LazyList Person.find("name = ?", "Smith").load();.
It is not possible to call other methods after load(). The load() method should be the last to be called in the chain:
Person.find("name = ?", "Smith").limit(10).load();.
This: will generate exception: Person.find("name = ?", "Smith").load().limit();.
load in class LazyList<T extends Model>public <E extends Model> LazyList<E> include(Class<? extends Model>... classes)
LazyListAuthor, Post
and Comment, where Author has many Posts and Post
has many Comments, then this query:
Listwill generate only three queries to database - one per model. All the dependencies (includes) will be eagerly loaded, and iteration via thetodayPosts = Post.where("post_date = ?", today).include(Author.class, Comment.class);
todayPosts list will not generate any more queries,
even when a post author and comments are requested. Use this with caution as this method can allocate
a lot of memory (obviously).
This method will not follow relationships of related models, but rather only relationships of the current
one.
include in class LazyList<T extends Model>classes - list of dependent classes. These classes represent models with which a current model has a
relationship.
LazyListpublic <E extends Model> LazyList<E> orderBy(String orderBy)
LazyListPerson.find(...).orderBy("department").orderBy("age")
orderBy in class LazyList<T extends Model>orderBy - order by clause. Examples: "department", "age desc", etc.
LazyListpublic <E extends Model> LazyList<E> offset(long offset)
LazyListList events = Event.find("mnemonic = ?", "GLUC").offset(101).limit(20).orderBy("history_event_id");
This will produce 20 records, starting from record 101. This is an efficient method, it will only retrieve records
that are necessary.
offset in class LazyList<T extends Model>LazyListpublic <E extends Model> LazyList<E> limit(long limit)
LazyListList<Event> events = Event.find("mnemonic = ?", "GLUC").offset(101).limit(20).orderBy("history_event_id");
This will produce 20 records, starting from record 101. This is an efficient method, it will only retrieve records
that are necessary.
limit in class LazyList<T extends Model>limit - how many records to retrieve.
LazyList
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||