public class MappingManager extends Object
Constructor and Description |
---|
MappingManager(Session session)
Creates a new
MappingManager using the provided Session with default
MapperConfiguration . |
MappingManager(Session session,
MappingConfiguration configuration)
Creates a new
MappingManager using the provided Session with custom configuration
to be inherited to each instantiated mapper. |
MappingManager(Session session,
MappingConfiguration configuration,
ProtocolVersion protocolVersion)
Creates a new
MappingManager using the provided Session with default
MapperConfiguration . |
MappingManager(Session session,
ProtocolVersion protocolVersion)
Creates a new
MappingManager using the provided Session with default
MapperConfiguration . |
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). |
MappingConfiguration |
getConfiguration()
Returns the
configuration used by this manager. |
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
with default
MapperConfiguration
.
Note that this constructor forces the initialization of the session (see
MappingManager(Session, ProtocolVersion)
if that is a problem for you).session
- the Session
to use.public MappingManager(Session session, ProtocolVersion protocolVersion)
MappingManager
using the provided Session
with default
MapperConfiguration
.
This constructor is only provided for backward compatibility: before 2.1.7, MappingManager
could be
built from an uninitialized session; since 2.1.7, the mapper needs to know the active protocol version to
adapt its internal requests, so MappingManager(Session)
will now initialize the session if needed.
If you rely on the session not being initialized, use this constructor and provide the version manually.session
- the Session
to use.protocolVersion
- the protocol version that will be used with this session.public MappingManager(Session session, MappingConfiguration configuration)
MappingManager
using the provided Session
with custom configuration
to be inherited to each instantiated mapper.
Note that this constructor forces the initialization of the session (see
MappingManager(Session, ProtocolVersion)
if that is a problem for you).session
- the Session
to use.configuration
- the MapperConfiguration
to use be used as default for instantiated mappers.public MappingManager(Session session, MappingConfiguration configuration, ProtocolVersion protocolVersion)
MappingManager
using the provided Session
with default
MapperConfiguration
.
This constructor is only provided for backward compatibility: before 2.1.7, MappingManager
could be
built from an uninitialized session; since 2.1.7, the mapper needs to know the active protocol version to
adapt its internal requests, so MappingManager(Session)
will now initialize the session if needed.
If you rely on the session not being initialized, use this constructor and provide the version manually.session
- the Session
to use.configuration
- the MapperConfiguration
to use be used as default for instantiated mappers.protocolVersion
- the protocol version that will be used with this session.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 MappingConfiguration getConfiguration()
configuration
used by this manager.configuration
used by this manager.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–2017. All rights reserved.