SPT Core API

com.sptci.jdo
Class GroupFactory

java.lang.Object
  extended by com.sptci.jdo.Factory<Group>
      extended by com.sptci.jdo.GroupFactory

public class GroupFactory
extends Factory<Group>

The repository class for interactions with the Group JDO persistent object.

The following code illustrates use of this class and associated JavaBean:

   import javax.jdo.PersistenceManager;

   import com.sptci.jdo.Group;
   import com.sptci.jdo.GroupFactory;

     ...
     GroupFactory factory = GroupFactory().getInstance();
     PersistenceManager pm = factory.getPersistenceManager();

     try
     {
       pm.currentTransaction().begin();

       String name = "test";
       Group group = factory.fetchByName( name, pm );
       if ( group != null )
       {
         group.getDescription();
       }

       pm.currentTransaction().commit();
     }
     finally
     {
       factory.close( pm );
     }
 

© Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: GroupFactory.java 4594 2009-01-29 17:43:03Z rakesh $
Author:
Rakesh Vidyadharan 2006-05-10

Field Summary
static GroupFactory groupFactory
          The singleton instance of the DAO.
 
Fields inherited from class com.sptci.jdo.Factory
logger
 
Constructor Summary
GroupFactory()
           
 
Method Summary
 long count(javax.jdo.PersistenceManager pm)
          Return a count of the total number of persistent instances of the Group object in the data store.
 Collection<Group> fetch(long start, long end, javax.jdo.PersistenceManager pm)
          Return a collection that contains all Group instances in the data store within the specified range.
 Collection<Group> fetchAll(javax.jdo.PersistenceManager pm)
          Return a collection of all the instances of Group objects available in the data store.
 Group fetchByName(String name, javax.jdo.PersistenceManager pm)
          Retrieve the Group uniquely identified by the specified NameDescription.name field value.
static GroupFactory getInstance()
          Return the singleton instance of this class.
 
Methods inherited from class com.sptci.jdo.Factory
addAlphabeticalIndex, begin, close, close, commit, count, delete, fetch, fetch, fetch, fetchAll, getPersistenceManager, removeStartLetter, rollback, save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

groupFactory

public static final GroupFactory groupFactory
The singleton instance of the DAO.

Constructor Detail

GroupFactory

public GroupFactory()
Method Detail

getInstance

public static GroupFactory getInstance()
Return the singleton instance of this class.

Returns:
The singleton repository instance.

fetchByName

public Group fetchByName(String name,
                         javax.jdo.PersistenceManager pm)
                  throws javax.jdo.JDOException
Retrieve the Group uniquely identified by the specified NameDescription.name field value.

Parameters:
name - The unique name to use to lookup the object.
pm - The persistence manager to use to fetch the object. It is assumed that an active transaction already exists.
Returns:
The appropriate object instance. Returns null if no object matching the specified name was found.
Throws:
javax.jdo.JDOException - If errors are encountered while fetching the record.

count

public long count(javax.jdo.PersistenceManager pm)
           throws javax.jdo.JDOException
Return a count of the total number of persistent instances of the Group object in the data store.

Parameters:
pm - The persistence manager to use to fetch the object count. It is assumed that an active transaction exists.
Returns:
The total number of instances in the data store.
Throws:
javax.jdo.JDOException - If errors are encountered while fetching the count.
See Also:
Factory.count( Class, PersistenceManager )

fetch

public Collection<Group> fetch(long start,
                               long end,
                               javax.jdo.PersistenceManager pm)
                        throws javax.jdo.JDOException
Return a collection that contains all Group instances in the data store within the specified range. This method is typically used to implement paginated view of the data in the data store. Use the count( PersistenceManager ) method to fetch the total number of persistent instances in the data store.

Parameters:
start - The index (inclusive) from which objects are to be retrieved from the data store.
end - The index (exclusive) till which objects are to be retrieved from the data store.
pm - The persistence manager to use. It is assumed that an active transaction exists (if non-transaction read is not enabled).
Returns:
The collection of objects. Returns an empty collection if no objects exist in the data store.
Throws:
javax.jdo.JDOException - If errors are encountered while fetching the objects.
See Also:
Factory.fetch( Class, long, long, PersistenceManager )

fetchAll

public Collection<Group> fetchAll(javax.jdo.PersistenceManager pm)
                           throws javax.jdo.JDOException
Return a collection of all the instances of Group objects available in the data store.

Parameters:
pm - The persistence manager to use to fetch the object. It is assumed that an active transaction already exists.
Returns:
The collection of object instances. Returns an empty collection if no objects are found.
Throws:
javax.jdo.JDOException - If errors are encountered while fetching the object or if no such ObjectId exists.

SPT Core API