On the surface, ObjectMap looks like a map we would find in the Java standard API with put
and get
methods. We would expect an interface similar to java.util.Map
with a name like ObjectMap. Though it doesn't quite provide all of the methods we've come to expect on a java.util.Map
, an ObjectMap provides a lot more functionality. We still have methods to get, put, update
, and remove
objects in a BackingMap though, so we'll start with those.
There are three methods for getting data into an ObjectMap. The put(Object key, Object value)
method does just what you think it would. An object value is placed into the map and is addressable by its key. Individual inserts into an ObjectMap are done using this put(Object key, Object value)
method. We've seen this a few times in our payment processing example:
session.begin(); paymentsMap.put(p.getId(), p); session.commit();
Remember, all of our interactions with the ObjectMap should be done under the context of a transaction. In this example...