com.gisgraphy.domain.repository
Interface IDao<T,PK extends java.io.Serializable>

All Known Subinterfaces:
IAdmDao, IAlternateNameDao, ICityDao, ICountryDao, IGisDao<T>, IGisFeatureDao, ILanguageDao, IOpenStreetMapDao, IStatsUsageDao
All Known Implementing Classes:
AdmDao, AirportDao, AlternateNameDao, AmuseParkDao, AqueducDao, ATMDao, BankDao, BarDao, BayDao, BeachDao, BridgeDao, BuildingDao, BusStationDao, CampDao, CanyonDao, CasinoDao, CastleDao, CemeteryDao, CirqueDao, CityDao, CitySubdivisionDao, CliffDao, CoastDao, ContinentDao, CountryDao, CourtHouseDao, CustomsPostDao, DamDao, DesertDao, FactoryDao, FallsDao, FarmDao, FieldDao, FishingAreaDao, FjordDao, ForestDao, GardenDao, GenericDao, GenericGisDao, GisFeatureDao, GolfDao, GorgeDao, GrassLandDao, GulfDao, HillDao, HospitalDao, HotelDao, HouseDao, IceDao, IslandDao, LakeDao, LanguageDao, LibraryDao, LightHouseDao, MallDao, MarshDao, MetroStationDao, MilitaryDao, MillDao, MineDao, MoleDao, MonumentDao, MoundDao, MountainDao, MuseumDao, OasisDao, ObservatoryPointDao, OceanDao, OpenStreetMapDao, OperaHouseDao, ParkDao, ParkingDao, PlantationDao, PolicePostDao, PoliticalEntityDao, PondDao, PortDao, PostOfficeDao, PrisonDao, PyramidDao, QuayDao, RailDao, RailRoadStationDao, RanchDao, RavinDao, ReefDao, ReligiousDao, ReserveDao, RestaurantDao, RoadDao, SchoolDao, SeaDao, SpringDao, StadiumDao, StatsUsageDao, StraitDao, StreamDao, StreetDao, TheaterDao, TowerDao, TreeDao, TunnelDao, UnderSeaDao, VineyardDao, VolcanoDao, WaterBodyDao, ZooDao

public interface IDao<T,PK extends java.io.Serializable>

Interface of a Generic (java-5 meaning) data access object

Author:
David Masclet
See Also:
IGisDao

Method Summary
 long count()
           
 int deleteAll()
          Delete all the object from the datastore
 void deleteAll(java.util.List<T> list)
          Delete all the specified object from the datastore
 boolean exists(PK id)
          Checks for existence of an object of type T using the id arg.
 void flushAndClear()
          Flush all Memory Objects to the database, and clear the L1 cache, of the current thread-bound Hibernate Session.
 T get(PK id)
          Retrieve the Object whith the specified primary key
 java.util.List<T> getAll()
          Generic method used to get all objects of a particular type.
 java.util.List<T> getAllPaginate(int from, int maxResults)
          Returns all object of a particular type (i.e getAllPaginate(2,5) will return the [2,3,4,5,6] object
 java.lang.Class<T> getPersistenceClass()
           
 void remove(T o)
          remove the object from the datastore
 T save(T o)
          Saves the passed object, and returns an attached entity.
 void setFlushMode(org.hibernate.FlushMode flushMode)
          Sets the flush mode (i.e. when objects are flushed to the database) of the current thread-bound session.
 

Method Detail

getPersistenceClass

java.lang.Class<T> getPersistenceClass()
Returns:
The class, this DAO 'process'

getAll

java.util.List<T> getAll()
Generic method used to get all objects of a particular type. This is the same as lookup up all rows in a table.

Returns:
List of populated objects (never return null, but an empty list)

getAllPaginate

java.util.List<T> getAllPaginate(int from,
                                 int maxResults)
Returns all object of a particular type (i.e getAllPaginate(2,5) will return the [2,3,4,5,6] object

Parameters:
from - The first result to return numbered from 1
maxResults - The maximum list size to return
Returns:
List of populated objects, (never return null, but an empty list)
Throws:
org.hibernate.HibernateException - if thrown by the Hibernate API
java.sql.SQLException - if thrown by JDBC API

flushAndClear

void flushAndClear()
Flush all Memory Objects to the database, and clear the L1 cache, of the current thread-bound Hibernate Session.

Throws:
org.hibernate.HibernateException - that Indicates problems flushing the session or talking to the database

save

T save(T o)
Saves the passed object, and returns an attached entity. It is very very very important to use the returned entity, because of the way the underlying mechanism possibly works. For instance, when using Db4o, this is completly useless, but when using JPA and the merge method of the EntityManager, things are going to be buggy (Duplicate Key exceptions) if you don't use the returned object. Please consult EJB3 (or the concrete persistence framework doc) Spec for more information about the way the merge method works.

Parameters:
o - The object to save
Returns:
The saved instance
Throws:
org.springframework.dao.DataAccessException - in case of errors

setFlushMode

void setFlushMode(org.hibernate.FlushMode flushMode)
Sets the flush mode (i.e. when objects are flushed to the database) of the current thread-bound session. By default, it is equivalent (in the case of JPA persistence) to FlushModeType.AUTO, which lets the persistence framework handle that issue. However, for performance reasons, it might be necessary to set it to FlushModeType.COMMIT. Warning : this sets the default flush mode of the session (either hibernate Session, JPA EntityManager, or similar) that is currently bound to the current thread. This means that it has absolutely no effect if no transaction is currently opened.

Parameters:
flushMode - The flush mode To set for this dao
Throws:
org.hibernate.HibernateException - if thrown by the Hibernate API
java.sql.SQLException - if thrown by JDBC API

remove

void remove(T o)
remove the object from the datastore

Parameters:
o - The object to remove
Throws:
org.springframework.dao.DataAccessException - In case of errors

exists

boolean exists(PK id)
Checks for existence of an object of type T using the id arg.

Parameters:
id - the id of the entity
Returns:
- true if it exists, false if it doesn't
Throws:
org.springframework.dao.DataAccessException - in case of errors

get

T get(PK id)
Retrieve the Object whith the specified primary key

Parameters:
id - the primarey key
Returns:
The object
Throws:
org.springframework.dao.DataAccessException - in case of errors

count

long count()
Returns:
the number of element in the Datastore
Throws:
org.hibernate.HibernateException - if thrown by the Hibernate API
java.sql.SQLException - if thrown by JDBC API

deleteAll

void deleteAll(java.util.List<T> list)
Delete all the specified object from the datastore

Parameters:
list - the list of element to delete
Throws:
org.springframework.dao.DataAccessException - in case of errors

deleteAll

int deleteAll()
Delete all the object from the datastore

Returns:
the number of deleted objects
Throws:
org.springframework.dao.DataAccessException - in case of errors


Copyright © 2010. All Rights Reserved.