public class H2MapToMap<K> extends java.util.HashMap<K,java.util.Map<?,?>> implements StoredCollection
After adding elements to this map, a HashMap.get(java.lang.Object)
operation needs to be performed, so that the
caller uses the db-backed collection.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
childTableName
The child map's table name.
|
private java.lang.String |
childWorkTable
The child map's work table name.
|
private java.lang.String |
clearSql
The map's clear SQL.
|
private DBHelper |
helper
The helper for SQL usage.
|
private java.lang.String |
insertSql
The map's insert SQL.
|
private java.lang.Class<?> |
key2Class
The child's map key class.
|
private java.lang.Class<?> |
keyClass
The map key class.
|
private java.lang.String |
mapClearSql
The child's map clear SQL.
|
private java.lang.String |
mapInsertSql
The child's map insert SQL.
|
private java.lang.String |
mapWorkClearSql
The child's work table clear SQL.
|
private java.lang.String |
mapWorkInsertSql
The child's work table insert SQL.
|
private java.lang.String |
tableName
The map's table name.
|
private java.lang.Class<?> |
valueClass
The child's map value class.
|
Constructor and Description |
---|
H2MapToMap(java.lang.Class<?> keyClass,
java.lang.Class<?> key2Class,
java.lang.Class<?> valueClass,
java.lang.String table,
DBHelper helper)
Create a new db-backed map, with the specified name.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the map and all its changes.
|
private void |
loadChildMaps()
Load all the child maps from the database, in their corresponding collections in the map.
|
void |
persist()
Persist this map and all the changes to the database.
|
java.util.Map<?,?> |
put(K key,
java.util.Map<?,?> value)
Perform a put operation.
|
void |
putAll(java.util.Map m)
Merge the specified map into this one.
|
java.util.Map<?,?> |
remove(java.lang.Object key)
Remove this key from the map.
|
boolean |
remove(java.lang.Object key,
java.lang.Object value)
This API is not currently supported.
|
clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putIfAbsent, replace, replace, replaceAll, size, values
finalize, getClass, notify, notifyAll, wait, wait, wait
compact, inPersist, unwrapValue, wrapValue
private DBHelper helper
private java.lang.Class<?> keyClass
private java.lang.Class<?> key2Class
private java.lang.Class<?> valueClass
private java.lang.String tableName
private final java.lang.String childTableName
private final java.lang.String childWorkTable
private final java.lang.String insertSql
private final java.lang.String clearSql
private final java.lang.String mapInsertSql
private final java.lang.String mapClearSql
private final java.lang.String mapWorkInsertSql
private final java.lang.String mapWorkClearSql
public H2MapToMap(java.lang.Class<?> keyClass, java.lang.Class<?> key2Class, java.lang.Class<?> valueClass, java.lang.String table, DBHelper helper)
keyClass
- The map's key class.key2Class
- The child's map key class.valueClass
- The map's value class.table
- The map's (and main table) name.helper
- The SQL helper.public java.util.Map<?,?> put(K key, java.util.Map<?,?> value)
The value map will be converted to a H2ChildMap
. Use a HashMap.get(java.lang.Object)
operation
to ensure the caller is using the db-backed map.
The access will be logged. This assumes the source AST requires for the key to have this specific value.
public void putAll(java.util.Map m)
put(K, java.util.Map<?, ?>)
to log the access
to the map.public java.util.Map<?,?> remove(java.lang.Object key)
If the key exists, then all changes related to it will be cleared.
public boolean remove(java.lang.Object key, java.lang.Object value)
public void clear()
clear
in interface StoredCollection
clear
in interface java.util.Map<K,java.util.Map<?,?>>
clear
in class java.util.HashMap<K,java.util.Map<?,?>>
public void persist()
persist
in interface StoredCollection
private void loadChildMaps()