public class JDBCRatingDAOBuilder extends Object
Construct and configure a JDBC rating DAO. Get a builder with JDBCRatingDAO.newBuilder()
.
public String getTableName()
public JDBCRatingDAOBuilder setTableName(String table)
public String getUserColumn()
public JDBCRatingDAOBuilder setUserColumn(@Nonnull String col)
public String getItemColumn()
public JDBCRatingDAOBuilder setItemColumn(@Nonnull String col)
public String getRatingColumn()
public JDBCRatingDAOBuilder setRatingColumn(@Nonnull String col)
public String getTimestampColumn()
public JDBCRatingDAOBuilder setTimestampColumn(@Nullable String col)
public boolean isCloseWhenClosed()
public JDBCRatingDAOBuilder setCloseWhenClosed(boolean close)
Configure whether the the DAO should close the database connection.
close
- true
to close the database connection with the DAO, false
to leave it open.public JDBCRatingDAOBuilder setStatementFactory(SQLStatementFactory fac)
Set the statement factory to be used by the DAO.
fac
- The statement factory.public SQLStatementFactory getStatementFactory()
Get the statement factory the DAO will use.
public JDBCRatingDAOBuilder setCacheBuilder(CacheBuilder<? super QueryKey,Object> cb)
Set a cache builder to use for making the DAO’s internal caches. The default builder uses soft value, a maximum size of 1000, and a timeout of 5 minutes after load.
cb
- The cache builder.public JDBCRatingDAOBuilder setCacheBuilder(CacheBuilderSpec spec)
Set a cache builder spec to use for making the DAO’s internal caches.
spec
- A cache builder spec.public JDBCRatingDAOBuilder setCacheBuilder(String spec)
Set the cache builder spec to use for making the DAO’s internal caches.
spec
- A cache builder spec.public JDBCRatingDAOBuilder setCache(Cache<QueryKey,Object> cache)
Set the cache to use for user and item queries. Multiple instances can use the same cache safely. This overides setCacheBuilder(com.google.common.cache.CacheBuilder)
.
cache
- The cache to use.public JDBCRatingDAO build(Connection con)
Create a DAO backed by a database connection.
con
- The database connection.con
.