org.jooq.impl
Class DAOImpl<R extends UpdatableRecord<R>,P,T>

java.lang.Object
  extended by org.jooq.impl.DAOImpl<R,P,T>
All Implemented Interfaces:
DAO<R,P,T>

public abstract class DAOImpl<R extends UpdatableRecord<R>,P,T>
extends Object
implements DAO<R,P,T>

A common base implementation for generated DAO's

Author:
Lukas Eder

Constructor Summary
protected DAOImpl(Table<R> table, Class<P> type)
           
protected DAOImpl(Table<R> table, Class<P> type, Factory create)
           
 
Method Summary
 long count()
          Count all records of the underlying table.
 void delete(Collection<P> objects)
          Performs a DELETE statement for a given set of POJOs
 void delete(P... objects)
          Performs a DELETE statement for a given set of POJOs
 void deleteById(Collection<T> ids)
          Performs a DELETE statement for a given set of IDs
 void deleteById(T... ids)
          Performs a DELETE statement for a given set of IDs
 boolean exists(P object)
          Checks if a given POJO exists
 boolean existsById(T id)
          Checks if a given ID exists
<Z> List<P>
fetch(Field<Z> field, Z... values)
          Find records by a given field and a set of values.
<Z> P
fetchOne(Field<Z> field, Z value)
          Find a unique record by a given field and a value.
 List<P> findAll()
          Find all records of the underlying table.
 P findById(T id)
          Find a record of the underlying table by ID.
protected abstract  T getId(P object)
           
 Table<R> getTable()
          Get the underlying table
 Class<P> getType()
          Get the underlying POJO type
 void insert(Collection<P> objects)
          Performs a batch INSERT statement for a given set of POJOs
 void insert(P... objects)
          Performs a batch INSERT statement for a given set of POJOs
 void insert(P object)
          Performs an INSERT statement for a given POJO
 void setFactory(Factory create)
          Inject an attached factory
 void update(Collection<P> objects)
          Performs a batch UPDATE statement for a given set of POJOs
 void update(P... objects)
          Performs a batch UPDATE statement for a given set of POJOs
 void update(P object)
          Performs an UPDATE statement for a given POJO
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DAOImpl

protected DAOImpl(Table<R> table,
                  Class<P> type)

DAOImpl

protected DAOImpl(Table<R> table,
                  Class<P> type,
                  Factory create)
Method Detail

setFactory

public final void setFactory(Factory create)
Inject an attached factory


insert

public final void insert(P object)
Description copied from interface: DAO
Performs an INSERT statement for a given POJO

Specified by:
insert in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
object - The POJO to be inserted

insert

public final void insert(P... objects)
Description copied from interface: DAO
Performs a batch INSERT statement for a given set of POJOs

Specified by:
insert in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
objects - The POJOs to be inserted
See Also:
DAO.insert(Collection)

insert

public final void insert(Collection<P> objects)
Description copied from interface: DAO
Performs a batch INSERT statement for a given set of POJOs

Specified by:
insert in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
objects - The POJOs to be inserted
See Also:
DAO.insert(Object...)

update

public final void update(P object)
Description copied from interface: DAO
Performs an UPDATE statement for a given POJO

Specified by:
update in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
object - The POJO to be updated

update

public final void update(P... objects)
Description copied from interface: DAO
Performs a batch UPDATE statement for a given set of POJOs

Specified by:
update in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
objects - The POJOs to be updated
See Also:
DAO.update(Collection)

update

public final void update(Collection<P> objects)
Description copied from interface: DAO
Performs a batch UPDATE statement for a given set of POJOs

Specified by:
update in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
objects - The POJOs to be updated
See Also:
DAO.update(Object...)

delete

public final void delete(P... objects)
Description copied from interface: DAO
Performs a DELETE statement for a given set of POJOs

Specified by:
delete in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
objects - The POJOs to be deleted
See Also:
DAO.delete(Collection)

delete

public final void delete(Collection<P> objects)
Description copied from interface: DAO
Performs a DELETE statement for a given set of POJOs

Specified by:
delete in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
objects - The POJOs to be deleted
See Also:
DAO.delete(Object...)

deleteById

public final void deleteById(T... ids)
Description copied from interface: DAO
Performs a DELETE statement for a given set of IDs

Specified by:
deleteById in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
ids - The IDs to be deleted
See Also:
DAO.delete(Collection)

deleteById

public final void deleteById(Collection<T> ids)
Description copied from interface: DAO
Performs a DELETE statement for a given set of IDs

Specified by:
deleteById in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
ids - The IDs to be deleted
See Also:
DAO.delete(Object...)

exists

public final boolean exists(P object)
Description copied from interface: DAO
Checks if a given POJO exists

Specified by:
exists in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
object - The POJO whose existence is checked
Returns:
Whether the POJO already exists

existsById

public final boolean existsById(T id)
Description copied from interface: DAO
Checks if a given ID exists

Specified by:
existsById in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
id - The ID whose existence is checked
Returns:
Whether the ID already exists

count

public final long count()
Description copied from interface: DAO
Count all records of the underlying table.

Specified by:
count in interface DAO<R extends UpdatableRecord<R>,P,T>
Returns:
The number of records of the underlying table

findAll

public final List<P> findAll()
Description copied from interface: DAO
Find all records of the underlying table.

Specified by:
findAll in interface DAO<R extends UpdatableRecord<R>,P,T>
Returns:
All records of the underlying table

findById

public final P findById(T id)
Description copied from interface: DAO
Find a record of the underlying table by ID.

Specified by:
findById in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
id - The ID of a record in the underlying table
Returns:
A record of the underlying table given its ID, or null if no record was found.

fetch

public final <Z> List<P> fetch(Field<Z> field,
                               Z... values)
Description copied from interface: DAO
Find records by a given field and a set of values.

Specified by:
fetch in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
field - The field to compare values against
values - The accepted values
Returns:
A list of records fulfilling field IN (values)

fetchOne

public final <Z> P fetchOne(Field<Z> field,
                            Z value)
Description copied from interface: DAO
Find a unique record by a given field and a value.

Specified by:
fetchOne in interface DAO<R extends UpdatableRecord<R>,P,T>
Parameters:
field - The field to compare value against
value - The accepted value
Returns:
A record fulfilling field = value, or null

getTable

public final Table<R> getTable()
Description copied from interface: DAO
Get the underlying table

Specified by:
getTable in interface DAO<R extends UpdatableRecord<R>,P,T>

getType

public final Class<P> getType()
Description copied from interface: DAO
Get the underlying POJO type

Specified by:
getType in interface DAO<R extends UpdatableRecord<R>,P,T>

getId

protected abstract T getId(P object)


Copyright © 2012. All Rights Reserved.