Package org.opennms.netmgt.dao.support
Class CreateIfNecessaryTemplate<T,D extends OnmsDao<T,?>>
- java.lang.Object
-
- org.opennms.netmgt.dao.support.UpsertTemplate<T,D>
-
- org.opennms.netmgt.dao.support.CreateIfNecessaryTemplate<T,D>
-
public abstract class CreateIfNecessaryTemplate<T,D extends OnmsDao<T,?>> extends UpsertTemplate<T,D>
Template for creating a row if and only if one doesn't already exists. This suffers from some of the same concurrency issues as described in theUpsertTemplate. See the detailed javadoc there for a description.- Author:
- brozow
-
-
Field Summary
-
Fields inherited from class org.opennms.netmgt.dao.support.UpsertTemplate
m_dao, m_transactionManager
-
-
Constructor Summary
Constructors Constructor Description CreateIfNecessaryTemplate(org.springframework.transaction.PlatformTransactionManager transactionManager, D dao)Create a CreateIfNecessaryTemplate using the given transactionManager to create transactions.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TdoInsert()Override this method to insert a new object into the database.protected TdoUpdate(T dbObj)There is no need to update the object for this case as we just return the object found.protected abstract Tquery()Override this method to execute the query that is used to determine if there is an existing object in the database-
Methods inherited from class org.opennms.netmgt.dao.support.UpsertTemplate
execute
-
-
-
-
Constructor Detail
-
CreateIfNecessaryTemplate
public CreateIfNecessaryTemplate(org.springframework.transaction.PlatformTransactionManager transactionManager, D dao)Create a CreateIfNecessaryTemplate using the given transactionManager to create transactions.
-
-
Method Detail
-
query
protected abstract T query()
Description copied from class:UpsertTemplateOverride this method to execute the query that is used to determine if there is an existing object in the database
-
doUpdate
protected T doUpdate(T dbObj)
There is no need to update the object for this case as we just return the object found.
-
doInsert
protected abstract T doInsert()
Description copied from class:UpsertTemplateOverride this method to insert a new object into the database. This method will be called when the query method returns null. A DataIntegrityViolationException should be thrown if the insert has already occurred. (This is the normal exception thrown when to objects with the same id are inserted).
-
-