public class MappingManager extends Object
Constructor and Description |
---|
MappingManager(Session session)
Creates a new
MappingManager using the provided Session . |
Modifier and Type | Method and Description |
---|---|
<T> T |
createAccessor(Class<T> klass)
Creates an accessor object based on the provided interface (that must be annotated by
a
Accessor annotation). |
Session |
getSession()
The underlying
Session used by this manager. |
<T> Mapper<T> |
mapper(Class<T> klass)
Creates a
Mapper for the provided class (that must be annotated by a
Table annotation). |
<T> TypeCodec<T> |
udtCodec(Class<T> klass)
Creates a
TypeCodec for the provided class (that must be annotated by
a UDT annotation). |
public MappingManager(Session session)
MappingManager
using the provided Session
.
Note that this constructor forces the initialization of the session.
session
- the Session
to use.public Session getSession()
Session
used by this manager.
Note that you can get obtain the Cluster
object corresponding
to that session using getSession().getCluster()
.
It is inadvisable to close the returned Session while this manager and its mappers are in use.
public <T> Mapper<T> mapper(Class<T> klass)
Mapper
for the provided class (that must be annotated by a
Table
annotation).
The MappingManager
only ever keeps one Mapper for each class, and so calling this
method multiple times on the same class will always return the same object.
If the type of any field in the class is an UDT
-annotated classes, a codec for that
class will automatically be created and registered with the underlying Cluster
.
This works recursively with UDTs nested in other UDTs or in collections.
T
- the type of the class to map.klass
- the (annotated) class for which to return the mapper.Mapper
object for class klass
.public <T> TypeCodec<T> udtCodec(Class<T> klass)
TypeCodec
for the provided class (that must be annotated by
a UDT
annotation).
This method also registers the codec against the underlying Cluster
.
In addition, the codecs for any nested UDTs will also be created and registered.
You don't need to call this method explicitly if you already call mapper(Class)
for a class that references this UDT class (creating a mapper will automatically
process all UDTs that it uses).
T
- the type of the class to map.klass
- the (annotated) class for which to return the codec.public <T> T createAccessor(Class<T> klass)
Accessor
annotation).
The MappingManager
only ever keep one Accessor for each class, and so calling this
method multiple time on the same class will always return the same object.
T
- the type of the accessor class.klass
- the (annotated) class for which to create an accessor object.klass
.Copyright © 2012–2015. All rights reserved.