public class MappingManager extends Object
Constructor and Description |
---|
MappingManager(Session session)
Creates a new
MappingManager using the provided Session . |
MappingManager(Session session,
ProtocolVersion protocolVersion)
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> UDTMapper<T> |
udtMapper(Class<T> klass)
Creates a
UDTMapper 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 (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
.
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 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.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> UDTMapper<T> udtMapper(Class<T> klass)
UDTMapper
for the provided class (that must be
annotated by a UDT
annotation).
The MappingManager
only ever keeps one UDTMapper
for each
class, and so calling this method multiple times on the same class will
always return the same object.
T
- the type of the class to map.klass
- the (annotated) class for which to return the mapper.UDTMapper
object for class klass
.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
.