palio.connectors.hibernate
Class GenericHibernateDAO<T,ID extends java.io.Serializable>

java.lang.Object
  extended by palio.connectors.hibernate.GenericHibernateDAO<T,ID>
Type Parameters:
T - Klasa persystentna.
ID - Klasa identyfikatora klasy persystentnej.
All Implemented Interfaces:
GenericDAO<T,ID>

public abstract class GenericHibernateDAO<T,ID extends java.io.Serializable>
extends java.lang.Object
implements GenericDAO<T,ID>

Klasa DAO warstwy Hibernate'a.

Author:
Grzegorz Tymiński

Constructor Summary
GenericHibernateDAO()
          Default constructor
 
Method Summary
 java.util.List<T> getAll()
          Pobiera listę wszystkich obiekty danej klasy.
 java.util.List<T> getByExample(T exampleInstance, java.lang.String... excludeProperty)
          Pobiera listę obiektów na podstawie przykładu obiektu pomijając wskazane atrybuty.
 T getById(ID id)
           
 T getById(ID id, boolean lock)
          Pobiera obiekt klasy na podstawie ID obiektu.
 java.lang.Class<T> getPersistentClass()
           
 T persist(T entity)
          Utrwala obiekt w bazie danych.
 boolean remove(T entity)
          Usuwa dany obiekt z bazy danych.
 void setSession(org.hibernate.Session s)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericHibernateDAO

public GenericHibernateDAO()
Default constructor

Method Detail

setSession

public void setSession(org.hibernate.Session s)
Parameters:
s - Sesja Hibernate'a połączenia z bazą danych.

getPersistentClass

public java.lang.Class<T> getPersistentClass()
Returns:
Klasa persystentna, którą dana warstawa DAO utrwala.

getById

public T getById(ID id,
                 boolean lock)
Description copied from interface: GenericDAO
Pobiera obiekt klasy na podstawie ID obiektu.

Specified by:
getById in interface GenericDAO<T,ID extends java.io.Serializable>
Parameters:
id - Identyfikator obiektu.
lock - Czy zablokować obiekt?
Returns:
Obiekt o podanym identyfikatorze lub null jeżeli dany obiekt nie istnieje w bazie danych.

getById

public T getById(ID id)

getAll

public java.util.List<T> getAll()
Description copied from interface: GenericDAO
Pobiera listę wszystkich obiekty danej klasy.

Specified by:
getAll in interface GenericDAO<T,ID extends java.io.Serializable>
Returns:
Lista wszystkich obiektów danej klasy.

getByExample

public java.util.List<T> getByExample(T exampleInstance,
                                      java.lang.String... excludeProperty)
Description copied from interface: GenericDAO
Pobiera listę obiektów na podstawie przykładu obiektu pomijając wskazane atrybuty.

Specified by:
getByExample in interface GenericDAO<T,ID extends java.io.Serializable>
Parameters:
exampleInstance - Przykładowy obiekt.
excludeProperty - Atrybuty do pominięcia.
Returns:
Lista obiektów na podstawie przykładu obiektu. Pomija wskazane atrybuty.

persist

public T persist(T entity)
Description copied from interface: GenericDAO
Utrwala obiekt w bazie danych.

Specified by:
persist in interface GenericDAO<T,ID extends java.io.Serializable>
Parameters:
entity - Obiekt do utrwalenia.
Returns:
Obiekt już utrwalony.

remove

public boolean remove(T entity)
Description copied from interface: GenericDAO
Usuwa dany obiekt z bazy danych.

Specified by:
remove in interface GenericDAO<T,ID extends java.io.Serializable>
Parameters:
entity - Obiekt do usunięcia.
Returns:
true jeżeli operacja zakończyła się sukcesem lub false w przeciwnym przypadku.