Class GenericDAOImpl<T>
java.lang.Object
com.rosivanyshyn.db.dao.implMySQL.GenericDAOImpl<T>
- Type Parameters:
T- Entity
- All Implemented Interfaces:
GenericDAO<T>
- Direct Known Subclasses:
AccountDAOImpl,ApartmentDAOImpl,BookingDAOImpl,OrderDAOImpl,ResponseToOrderDAOImpl
Generic DAO interface implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceSubstitute Values in DB Queries through statementprotected static interfaceExtract entity from ResultSet in JavaBeanprotected static interfaceReceive getGeneratedKeys from preparedStatement
and update current entity for which them was generated. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCount the number of rows in the last query
Last query should have SQL_CALC_FOUND_ROWS part!!!delete(Connection con, Long id) Delete object from respective table by id.get(Connection con, Long id) Get object from respective table by id.getAll(Connection con) Get all objects from respective table.getByField(Connection con, String field, Object value) Find entity from respective table by field and value.getFew(Connection con, int start, int total) Get few objects from respective table.getWithDynamicQuery(Connection con, String secondQueryPart, Object... fields) Get objects from respective table by using query builder string partinsert(Connection con, T object) Add specific object to respective table.update(Connection con, T object) Update object in respective table.
-
Field Details
-
LOG
protected static final org.apache.log4j.Logger LOG -
className
-
-
Constructor Details
-
GenericDAOImpl
public GenericDAOImpl()
-
-
Method Details
-
insert
Description copied from interface:GenericDAOAdd specific object to respective table.- Specified by:
insertin interfaceGenericDAO<T>- Parameters:
con- connection to databaseobject- object- Returns:
- Boolean operation result
-
get
Description copied from interface:GenericDAOGet object from respective table by id.- Specified by:
getin interfaceGenericDAO<T>- Parameters:
con- connection to databaseid- object id- Returns:
- T object result field
-
getAll
Description copied from interface:GenericDAOGet all objects from respective table.- Specified by:
getAllin interfaceGenericDAO<T>- Parameters:
con- connection to database- Returns:
- ArrayList
result array
-
getFew
Description copied from interface:GenericDAOGet few objects from respective table.
Example - start 15, total 50, return records from 15 to 65 (Not from 15 to 50!!!)- Specified by:
getFewin interfaceGenericDAO<T>- Parameters:
con- connection to databasestart- which record to start sampling fromtotal- records count to get- Returns:
- ArrayList
result array
-
getByField
Description copied from interface:GenericDAOFind entity from respective table by field and value.- Specified by:
getByFieldin interfaceGenericDAO<T>- Parameters:
con- connection to databasefield- user field. Doesn`t support foreign keys!!!value- user value- Returns:
- T field
-
getWithDynamicQuery
Description copied from interface:GenericDAOGet objects from respective table by using query builder string part- Specified by:
getWithDynamicQueryin interfaceGenericDAO<T>- Parameters:
con- connection to databasesecondQueryPart- query builder string partfields- fields for insertion in query builder string part statement- Returns:
- ArrayList
result array
-
update
Description copied from interface:GenericDAOUpdate object in respective table.- Specified by:
updatein interfaceGenericDAO<T>- Parameters:
con- connection to databaseobject- object to update- Returns:
- Boolean operation result
-
delete
Description copied from interface:GenericDAODelete object from respective table by id.- Specified by:
deletein interfaceGenericDAO<T>- Parameters:
con- connection to databaseid- object id- Returns:
- Boolean operation result
-
countRowsInLastQuery
Description copied from interface:GenericDAOCount the number of rows in the last query
Last query should have SQL_CALC_FOUND_ROWS part!!!- Specified by:
countRowsInLastQueryin interfaceGenericDAO<T>- Parameters:
con- connection to database- Returns:
- number of rows
-