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
Provides finder functionality for use with "Dependency Injection style" use of Ebean.
Note that typically users would extend BeanRepository rather than BeanFinder.
public class CustomerFinder extends BeanFinder<Long,Customer> {
@Inject
public CustomerFinder(Database database) {
super(Customer.class, database);
}
// ... add customer specific finders
}
-
Method Summary
Modifier and TypeMethodDescriptionReturn the current transaction.db()Return the Database to use.Return typically a different Database to the default.voiddeleteById(I id) Delete a bean by Id.findAll()Retrieves all entities of the given type.Retrieves an entity by ID.findByIdOrEmpty(I id) Find an entity by ID returning an Optional.voidflush()Flush the JDBC batch on the current transaction.Creates an entity reference for this ID.
-
Method Details
-
db
Return the Database to use. -
currentTransaction
Return the current transaction. -
flush
Flush the JDBC batch on the current transaction. -
db
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
Creates an entity reference for this ID.Equivalent to
Database.reference(Class, Object) -
findById
Retrieves an entity by ID. -
findByIdOrEmpty
Find an entity by ID returning an Optional. -
deleteById
Delete a bean by Id. -
findAll
Retrieves all entities of the given type.
-