Package wicket.contrib.phonebook
Class HibernateContactDao
- java.lang.Object
-
- wicket.contrib.phonebook.HibernateContactDao
-
- All Implemented Interfaces:
ContactDao
public class HibernateContactDao extends Object implements ContactDao
implementsContactDao.- Author:
- igor
-
-
Constructor Summary
Constructors Constructor Description HibernateContactDao()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.hibernate.QuerybuildFindQuery(QueryParam qp, Contact filter, boolean count)builds a query object to satisfy the provided parametersintcount(Contact filter)Return the number of Contacts in the DB.voiddelete(long id)Delete aContactfrom the DB, given it's id.Iterator<Contact>find(QueryParam qp, Contact filter)Query the DB, using the supplied query details.protected org.hibernate.SessiongetSession()Helper method for retrieving hibernate sessionList<String>getUniqueLastNames()Returns a list of unique last namesContactload(long id)Load aContactfrom the DB, given it's id .Contactsave(Contact contact)Save the contact to the DBvoidsetSessionFactory(org.hibernate.SessionFactory factory)Setter for session factory.
-
-
-
Method Detail
-
setSessionFactory
public void setSessionFactory(org.hibernate.SessionFactory factory)
Setter for session factory. Spring will use this to inject the session factory into the dao.- Parameters:
factory- hibernate session factory
-
getSession
protected org.hibernate.Session getSession()
Helper method for retrieving hibernate session- Returns:
- hibernate session
-
load
public Contact load(long id)
Load aContactfrom the DB, given it's id .- Specified by:
loadin interfaceContactDao- Parameters:
id- The id of the Contact to load.- Returns:
- Contact
-
save
public Contact save(Contact contact)
Save the contact to the DB- Specified by:
savein interfaceContactDao- Parameters:
contact-- Returns:
- persistent instance of contact
-
delete
public void delete(long id)
Delete aContactfrom the DB, given it's id.- Specified by:
deletein interfaceContactDao- Parameters:
id- The id of the Contact to delete.
-
find
public Iterator<Contact> find(QueryParam qp, Contact filter)
Query the DB, using the supplied query details.- Specified by:
findin interfaceContactDao- Parameters:
qp- Query Parameters to use.- Returns:
- The results of the query as an Iterator.
-
count
public int count(Contact filter)
Return the number of Contacts in the DB.- Specified by:
countin interfaceContactDao- Returns:
- count
-
getUniqueLastNames
public List<String> getUniqueLastNames()
Returns a list of unique last names- Specified by:
getUniqueLastNamesin interfaceContactDao- Returns:
- the list of all unique last names in the database
-
buildFindQuery
protected org.hibernate.Query buildFindQuery(QueryParam qp, Contact filter, boolean count)
builds a query object to satisfy the provided parameters- Parameters:
qp- sorting and paging criteriafilter- filter criteriacount- true if this is a query meant to retrieve the number of rows- Returns:
- query object that satisfies the provided criteria
-
-