Package tenapull.data.persistence
Class MapLookupDao<POJO extends MapLookupPojo<POJO>>
java.lang.Object
tenapull.data.persistence.Dao<POJO>
tenapull.data.persistence.AbstractPojoLookupDao<POJO>
tenapull.data.persistence.MapLookupDao<POJO>
- Type Parameters:
POJO
- the type parameter
public class MapLookupDao<POJO extends MapLookupPojo<POJO>> extends AbstractPojoLookupDao<POJO>
Dao used for map lookup pojos, where a DB record can be matched by a search map
or the _match function. This pojo type is often (though not always) used for records with
a composite candidate key (e.g. ScanHost, with a host_id and scan_id) but may
also be used for immutable object lookups in place of a hash lookup for very simple
object structures where the overhead of a hash may not be worth the indexing benefit
it provides
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description MapLookupDao(java.lang.Class<POJO> pojoType)
Instantiates a new MapLookupDao for the pojo type provided. -
Method Summary
Modifier and Type Method Description protected POJO
checkedGetOrCreate(POJO pojo)
Abstract method to be implemented by subclasses, which is invoked after the instance array has already been checked for the instance without success (assuming the pojo had a primary key id set) and the pojo has already had its _prepare method invokedprotected POJO
checkedUnproxy(org.hibernate.proxy.HibernateProxy pojo)
Invoked by unproxy after it has confirmed that the pojo is not null and is an uninitialized instance of HibernateProxyprotected POJO
finalizeResult(POJO pojo, POJO result)
Perform any needed final operations on the "canonical" pojo before returning it to the caller of getOrCreate.static <P extends DbPojo, D extends Dao<P>>
Dget(java.lang.Class<P> objectLookupPojoClass)
Get the MapLookupDao for the provided pojo typestatic java.util.Map<java.lang.String,java.lang.Object>
makeSearchMapFromJson(com.fasterxml.jackson.databind.JsonNode searchMapNode)
Make a pojo search map from a json nodejava.lang.String
toString()
Methods inherited from class tenapull.data.persistence.AbstractPojoLookupDao
getOrCreate, getOrCreate, searchForInstanceId
Methods inherited from class tenapull.data.persistence.Dao
borrowSessionsFrom, delete, delete, findByExactPojo, findByPojoNonNull, findByPropertyEqual, findByPropertyEqual, getAccessMap, getAll, getAttributeMap, getById, getGetterMap, getIdMap, getLogger, getPojoType, getSession, hasActiveSession, holdSession, insert, insert, keyValueSearch, lenderHasActiveSession, makeExactPojoSearchMap, makePojoNonNullSearchMap, mapSearch, releaseSession, saveOrUpdate, saveOrUpdate, unproxy
-
Constructor Details
-
MapLookupDao
Instantiates a new MapLookupDao for the pojo type provided.- Parameters:
pojoType
-- Throws:
java.lang.IllegalArgumentException
- if a dao has already been instantiated for the provided pojoType
-
-
Method Details
-
checkedGetOrCreate
Description copied from class:AbstractPojoLookupDao
Abstract method to be implemented by subclasses, which is invoked after the instance array has already been checked for the instance without success (assuming the pojo had a primary key id set) and the pojo has already had its _prepare method invoked- Specified by:
checkedGetOrCreate
in classAbstractPojoLookupDao<POJO extends MapLookupPojo<POJO>>
- Parameters:
pojo
- the pojo- Returns:
- the pojo
-
finalizeResult
Description copied from class:AbstractPojoLookupDao
Perform any needed final operations on the "canonical" pojo before returning it to the caller of getOrCreate. Typically, if the canonical pojo were a different instance than the one provided, the _set method would be called on the canonical instance to update it so it reflects the values of the new instance- Specified by:
finalizeResult
in classAbstractPojoLookupDao<POJO extends MapLookupPojo<POJO>>
- Parameters:
pojo
- the pojoresult
- the result- Returns:
- the pojo
-
checkedUnproxy
Description copied from class:Dao
Invoked by unproxy after it has confirmed that the pojo is not null and is an uninitialized instance of HibernateProxy- Overrides:
checkedUnproxy
in classDao<POJO extends MapLookupPojo<POJO>>
- Parameters:
pojo
- the pojo- Returns:
- the pojo
-
makeSearchMapFromJson
public static java.util.Map<java.lang.String,java.lang.Object> makeSearchMapFromJson(com.fasterxml.jackson.databind.JsonNode searchMapNode) throws javax.json.JsonExceptionMake a pojo search map from a json node- Parameters:
searchMapNode
- the json node to make the search map for- Returns:
- the search map
- Throws:
javax.json.JsonException
- if there is an error processing json
-
toString
public java.lang.String toString()- Overrides:
toString
in classDao<POJO extends MapLookupPojo<POJO>>
-
get
public static <P extends DbPojo, D extends Dao<P>> D get(java.lang.Class<P> objectLookupPojoClass)Get the MapLookupDao for the provided pojo type- Type Parameters:
P
- the type parameterD
- the type parameter- Parameters:
objectLookupPojoClass
- the object lookup pojo class- Returns:
- the d
-