Class GenericDao<T>
java.lang.Object
me.nickhanson.codeforge.persistence.GenericDao<T>
Generic, concrete data helper used by DAOs to perform common CRUD operations
with Hibernate SessionFactory. This is intentionally not a Spring bean to
match the class pattern used in the project.
- Author:
- Nick Hanson
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDelete the given entity.findByPropertyEqual(String property, Object value) Find entities where a property equals a given value.getAll()Get all entities of type T, ordered by ID ascending.Get entity by its primary key ID.voidsaveOrUpdate(T entity) Save or update the given entity.
-
Constructor Details
-
GenericDao
-
-
Method Details
-
getById
Get entity by its primary key ID.- Parameters:
id- the primary key ID- Returns:
- the entity instance or null if not found
-
getAll
Get all entities of type T, ordered by ID ascending.- Returns:
- list of all entities
-
saveOrUpdate
Save or update the given entity.- Parameters:
entity- the entity to save or update
-
delete
Delete the given entity.- Parameters:
entity- the entity to delete
-
findByPropertyEqual
Find entities where a property equals a given value.- Parameters:
property- the property namevalue- the value to match- Returns:
- list of matching entities
-