Package io.ebean
Class BeanFinder<I,T>
- java.lang.Object
-
- io.ebean.BeanFinder<I,T>
-
- Type Parameters:
I
- The ID typeT
- The Bean type
- Direct Known Subclasses:
BeanRepository
public abstract class BeanFinder<I,T> extends Object
Provides finder functionality for use with "Dependency Injection style" use of Ebean.Note that typically users would extend BeanRepository rather than BeanFinder.
{@code public class CustomerFinder extends BeanFinder
{
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Transaction
currentTransaction()
Return the current transaction.Database
db()
Return the Database to use.Database
db(String server)
Return typically a different Database to the default.void
deleteById(I id)
Delete a bean by Id.List<T>
findAll()
Retrieves all entities of the given type.T
findById(I id)
Retrieves an entity by ID.Optional<T>
findByIdOrEmpty(I id)
Find an entity by ID returning an Optional.void
flush()
Flush the JDBC batch on the current transaction.T
ref(I id)
Creates an entity reference for this ID.
-
-
-
Method Detail
-
currentTransaction
public Transaction currentTransaction()
Return the current transaction.
-
flush
public void flush()
Flush the JDBC batch on the current transaction.
-
db
public Database db(String server)
Return typically a different Database to the default.This is equivalent to
DB.byName(String)
- Parameters:
server
- The name of the Database. If this is null then the default Database is returned.
-
ref
@Nonnull public T ref(I id)
Creates an entity reference for this ID.Equivalent to
Database.getReference(Class, Object)
-
findByIdOrEmpty
@Nullable public Optional<T> findByIdOrEmpty(I id)
Find an entity by ID returning an Optional.
-
deleteById
public void deleteById(I id)
Delete a bean by Id.
-
-