com.jamasoftware.contour.dao
Interface GenericDao


public interface GenericDao


Method Summary
 void addOrUpdateObject(java.lang.Object object)
           
 void attachObject(java.lang.Object obj)
          If the underlying ORM supports object caching, this method makes sure this object is cached and associated with the current session.
 void clearObjectCache()
          If the underlying ORM supports object caching, this method clears that cache, forcing any future object retrieval to come fresh from the database.
 int count(java.lang.Class<?> cls, java.util.Collection<com.jamasoftware.contour.service.restriction.Restriction> restrictions)
          Counts the number of results, given the restrictions, in an efficient manner.
 void detatchObject(java.lang.Object obj)
          If the underlying ORM supports object caching, this method makes sure this object isn't cached, and therefore isn't returned by any service methods without retrieving from the database fresh.
 java.lang.String doNotFlushTemporarily()
          Sets up the current session to never flush unless explicitly asked via flush().
 void flush()
          Makes sure that any pending changes or commands to be applied to the database are run or executed.
<T> T
getObject(java.lang.Class<T> cls, java.io.Serializable id)
          Gets an object by its unique identifier.
 DomainObjectBase getObjectByScopeRef(java.lang.Integer scope, java.lang.Integer refId)
          Gets an object by scope/ref
 java.util.List<DomainObjectBase> getObjectListByScopeRef(java.lang.Integer scope, java.util.List<java.lang.Integer> refIds)
           
<T> java.util.List<T>
getObjects(java.lang.Class<T> cls, java.util.Collection<com.jamasoftware.contour.service.restriction.Restriction> restrictions, java.lang.Integer firstResult, java.lang.Integer maxResults, com.jamasoftware.contour.service.search.SorterInfo sortInfo)
          Gets a List of objects of type T.
 java.util.List<? extends DomainObjectBase> getReferencesToScope(DomainObjectBase domainObj, java.lang.Class<?> tableName)
           
<T extends ScopedObject>
java.util.List<T>
getScopedObjects(java.lang.Class<T> cls, java.lang.Integer scopeId, java.lang.Integer refId)
           
 void initialize(java.lang.Object proxy)
          Force initialization of a proxy object.
 void makeReadOnly(java.lang.Object obj, boolean readonly)
          If readOnly is true, makes the object read only from the view of the underlying ORM.
 java.lang.Object mergeObject(java.lang.Object obj)
           
<T> boolean
objectExists(java.lang.Class<T> cls, java.io.Serializable id)
          Returns whether or not an object exists.
 void quickFlush()
          Performs a quick session flush to persist items in database.
 void resumeNormalFlushOperation(java.lang.String flushMode)
          Expected parameter is that which is returned from doNotFlushTemporarily().
 void updateObjectRefForScope(java.lang.Integer scope, java.lang.Integer oldRefId, java.lang.Integer newRefId, boolean flush)
          Performs an update for all scope/ref combinations pointing to the oldRefId to point to the newRefId
 

Method Detail

getReferencesToScope

java.util.List<? extends DomainObjectBase> getReferencesToScope(DomainObjectBase domainObj,
                                                                java.lang.Class<?> tableName)

quickFlush

void quickFlush()
Performs a quick session flush to persist items in database. Useful for getting around Oracle's save and retrieve issues in the same session. This is faster than flush() because it does not flush to indexes.


flush

void flush()
Makes sure that any pending changes or commands to be applied to the database are run or executed. For example, in a Hibernate implementation, this would flush the current session.


mergeObject

java.lang.Object mergeObject(java.lang.Object obj)

doNotFlushTemporarily

java.lang.String doNotFlushTemporarily()
Sets up the current session to never flush unless explicitly asked via flush().

Returns:
A string representation of the current flush mode, which should be given to resumeNormalFlushOperation(String) when done with manual flush mode

resumeNormalFlushOperation

void resumeNormalFlushOperation(java.lang.String flushMode)
Expected parameter is that which is returned from doNotFlushTemporarily(). This will revert the current session back to the flush mode that was set before that call was made.

Parameters:
flushMode - The flush mode returned from doNotFlushTemporarily()

detatchObject

void detatchObject(java.lang.Object obj)
If the underlying ORM supports object caching, this method makes sure this object isn't cached, and therefore isn't returned by any service methods without retrieving from the database fresh. In a Hibernate implementation, this would call evict() on the current session.

Parameters:
obj - The object that should not be cached.

attachObject

void attachObject(java.lang.Object obj)
If the underlying ORM supports object caching, this method makes sure this object is cached and associated with the current session. In a Hibernate implementation, this would call lock() on the current session.

Parameters:
obj - The object that should be associated with the current session

makeReadOnly

void makeReadOnly(java.lang.Object obj,
                  boolean readonly)
If readOnly is true, makes the object read only from the view of the underlying ORM. That is, it will no longer be considered changeable, and this can provide performance improvements when determining whether objects are dirty or not. If readOnly is false, this method has the opposite affect.

Parameters:
obj - An object to make read only or not
readonly - Whether the object should be readonly or not

clearObjectCache

void clearObjectCache()
If the underlying ORM supports object caching, this method clears that cache, forcing any future object retrieval to come fresh from the database. In a Hibernate implementation, this would call clear() on the current session.


count

int count(java.lang.Class<?> cls,
          java.util.Collection<com.jamasoftware.contour.service.restriction.Restriction> restrictions)
Counts the number of results, given the restrictions, in an efficient manner. Without behind-the-scenes changes, this number will equal the size of the list return by #getObjects(Class, Collection, PageInfo, SorterInfo) when paging information isn't applied, with the same class and collection of restrictions.

Parameters:
cls - The mapping class that the restrictions apply to
restrictions - The collection of Restrictions, or null
Returns:
The number of results that would be returned by #getObjects(Class, Collection, PageInfo, SorterInfo)

getObject

<T> T getObject(java.lang.Class<T> cls,
                java.io.Serializable id)
Gets an object by its unique identifier.

Type Parameters:
T - The type of the object
Parameters:
cls - The class of persisted object
id - The id
Returns:
The found object, or null

getScopedObjects

<T extends ScopedObject> java.util.List<T> getScopedObjects(java.lang.Class<T> cls,
                                                            java.lang.Integer scopeId,
                                                            java.lang.Integer refId)

getObjectByScopeRef

DomainObjectBase getObjectByScopeRef(java.lang.Integer scope,
                                     java.lang.Integer refId)
Gets an object by scope/ref

Parameters:
scope - A Scope integer
refId - The referenced id
Returns:
The found object, or null

getObjectListByScopeRef

java.util.List<DomainObjectBase> getObjectListByScopeRef(java.lang.Integer scope,
                                                         java.util.List<java.lang.Integer> refIds)

updateObjectRefForScope

void updateObjectRefForScope(java.lang.Integer scope,
                             java.lang.Integer oldRefId,
                             java.lang.Integer newRefId,
                             boolean flush)
Performs an update for all scope/ref combinations pointing to the oldRefId to point to the newRefId

Parameters:
scope - A scope
oldRefId - A refId to update from
newRefId - A refId to update to
flush - Whether to flush after update statements are performed. This is recommended, as the update statements don't bring objects in memory, so one could get stale data if later querying for data that these updates affected.

objectExists

<T> boolean objectExists(java.lang.Class<T> cls,
                         java.io.Serializable id)
Returns whether or not an object exists.

Type Parameters:
T - The type of the object
Parameters:
cls - The class of persisted object
id - The id
Returns:
true if the object exists, otherwise false

getObjects

<T> java.util.List<T> getObjects(java.lang.Class<T> cls,
                                 java.util.Collection<com.jamasoftware.contour.service.restriction.Restriction> restrictions,
                                 java.lang.Integer firstResult,
                                 java.lang.Integer maxResults,
                                 com.jamasoftware.contour.service.search.SorterInfo sortInfo)
Gets a List of objects of type T.

Type Parameters:
T - The type of objects being returned
Parameters:
cls - The mapping class for the object type
restrictions - The collection of Restrictions, or null
firstResult - The index of the first result to return (null returns beginning of list)
maxResults - The maximum number of results to return (null for all results)
sortInfo - The sorting information, if applicable
Returns:
The list of objects found

addOrUpdateObject

void addOrUpdateObject(java.lang.Object object)

initialize

void initialize(java.lang.Object proxy)
Force initialization of a proxy object.

Parameters:
proxy -


Copyright (c) 2010 Jama Software, Inc. All Rights Reserved.