Module io.ebean.api
Package io.ebean

Class FetchConfig

java.lang.Object
io.ebean.FetchConfig
All Implemented Interfaces:
Serializable

public final class FetchConfig extends Object implements Serializable
Defines how a relationship is fetched via either normal SQL join, a eager secondary query, via lazy loading or via eagerly hitting L2 cache.


 // Normal fetch join results in a single SQL query
 List<Order> list = DB.find(Order.class).fetch("details").findList();

 

Example: Using a "query join" instead of a "fetch join" we instead use 2 SQL queries



 // This will use 2 SQL queries to build this object graph
 List<Order> list =
     DB.find(Order.class)
         .fetch("details", FetchConfig.ofQuery())
         .findList();

 // query 1) find order
 // query 2) find orderDetails where order.id in (?,?...) // first 100 order id's

 
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
    Return the batch size for fetching.
    int
     
    boolean
    Return true if the fetch should use the L2 cache.
    boolean
    Return true if the fetch should try to use SQL join.
    boolean
    Return true if the fetch should be a lazy query.
    boolean
    Return true if the fetch should be a eager secondary query.
    Return FetchConfig to eagerly fetch the relationship using L2 cache.
    Return FetchConfig to fetch the relationship using SQL join.
    Return FetchConfig to lazily load the relationship.
    ofLazy(int batchSize)
    Return FetchConfig to lazily load the relationship specifying the batch size.
    Return FetchConfig to eagerly fetch the relationship using a secondary query.
    ofQuery(int batchSize)
    Return FetchConfig to eagerly fetch the relationship using a secondary with a given batch size.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • ofCache

      public static FetchConfig ofCache()
      Return FetchConfig to eagerly fetch the relationship using L2 cache.

      Any cache misses will be loaded by secondary query to the database.

    • ofQuery

      public static FetchConfig ofQuery()
      Return FetchConfig to eagerly fetch the relationship using a secondary query.
    • ofQuery

      public static FetchConfig ofQuery(int batchSize)
      Return FetchConfig to eagerly fetch the relationship using a secondary with a given batch size.
    • ofLazy

      public static FetchConfig ofLazy()
      Return FetchConfig to lazily load the relationship.
    • ofLazy

      public static FetchConfig ofLazy(int batchSize)
      Return FetchConfig to lazily load the relationship specifying the batch size.
    • ofDefault

      public static FetchConfig ofDefault()
      Return FetchConfig to fetch the relationship using SQL join.
    • getBatchSize

      public int getBatchSize()
      Return the batch size for fetching.
    • isCache

      public boolean isCache()
      Return true if the fetch should use the L2 cache.
    • isQuery

      public boolean isQuery()
      Return true if the fetch should be a eager secondary query.
    • isLazy

      public boolean isLazy()
      Return true if the fetch should be a lazy query.
    • isJoin

      public boolean isJoin()
      Return true if the fetch should try to use SQL join.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object