de.nava.informa.utils.manager.hibernate
Class PersistenceManager

java.lang.Object
  extended by de.nava.informa.utils.manager.hibernate.NonCachingPersistenceManager
      extended by de.nava.informa.utils.manager.hibernate.PersistenceManager
All Implemented Interfaces:
PersistenceManagerIF

public class PersistenceManager
extends NonCachingPersistenceManager

Hibernate Persistence Manager. This manager talks to Hibernate to store / restore persistence data. Manager is multi-thread safe. It follows the rule of identities and multiple calls to getting methods (for example, getGroups()) return the same instances of objects. This makes life of developers and client applications easier.

It's not enough to directly update the fields of objects in order to have the same fields updated persistently. You should explicitly call updateXXXX() methods to transfer changes to the storage. The decision to make explicit updates based on the fact that automatic flushing changes to database each time the value of some property changes will take too much resources when many properties are updated in a single block of code.

Note that the manager itself does no efforts to initialize Hibernate!
It uses system properties as overrides of normal Hibernate inialization ways, like hibernate.properties and hibernate.cfg.xml files which are loaded when this manager requires Hibernate services for the first time. Please, read Hibernate documentation to learn what files and where should be placed to initialize the product properly.

Please also note, that this implementation requires to be the only source of changes to Hibernate data storage (database or something else) to operate normally! Basically it is not a problem at all, but if you find that it's not your case, please let us know.

Author:
Aleksey Gureev (spyromus@noizeramp.com)

Constructor Summary
PersistenceManager()
           
 
Method Summary
 ChannelGroupIF createGroup(String title)
          Creates new group of channels in persistent storage.
 void deleteGroup(ChannelGroupIF group)
          Deletes group from persistent storage.
 ChannelGroupIF[] getGroups()
          Returns the list of groups available in database.
 void mergeGroups(ChannelGroupIF first, ChannelGroupIF second)
          Takes channels from the second group and put them all in first group.
 
Methods inherited from class de.nava.informa.utils.manager.hibernate.NonCachingPersistenceManager
addChannelToGroup, createChannel, createItem, createItem, deleteChannel, deleteItem, removeChannelFromGroup, updateChannel, updateGroup, updateItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceManager

public PersistenceManager()
Method Detail

createGroup

public ChannelGroupIF createGroup(String title)
                           throws PersistenceManagerException
Creates new group of channels in persistent storage.

Specified by:
createGroup in interface PersistenceManagerIF
Overrides:
createGroup in class NonCachingPersistenceManager
Parameters:
title - title of the group.
Returns:
initialized and persisted group object.
Throws:
PersistenceManagerException - in case of any problems.

deleteGroup

public void deleteGroup(ChannelGroupIF group)
                 throws PersistenceManagerException
Deletes group from persistent storage.

Specified by:
deleteGroup in interface PersistenceManagerIF
Overrides:
deleteGroup in class NonCachingPersistenceManager
Parameters:
group - group to delete.
Throws:
PersistenceManagerException - in case of any problems.

mergeGroups

public void mergeGroups(ChannelGroupIF first,
                        ChannelGroupIF second)
                 throws PersistenceManagerException
Takes channels from the second group and put them all in first group. Then second group is deleted.

Specified by:
mergeGroups in interface PersistenceManagerIF
Overrides:
mergeGroups in class NonCachingPersistenceManager
Parameters:
first - first group of channels.
second - second group of channels.
Throws:
PersistenceManagerException - in case of any problems.

getGroups

public ChannelGroupIF[] getGroups()
                           throws PersistenceManagerException
Returns the list of groups available in database.

Specified by:
getGroups in interface PersistenceManagerIF
Overrides:
getGroups in class NonCachingPersistenceManager
Returns:
list of groups.
Throws:
PersistenceManagerException - in case of any problems.


Copyright © 2002-2007 Niko Schmuck. All Rights Reserved.