SqlSession class
A session for running mapped statements.
The equivalent of MyBatis SqlSession:
- selectList: every matching row
- selectOne: one row or null; throws TooManyResultsException for more
- insert: returns the new rowid
- update: returns the affected row count
- delete: returns the affected row count
Example:
// statements are addressed as 'namespace.id'
final list = await session.selectList('PersonMapper.selectPersonList', {'name': 'Hong'});
final person = await session.selectOne('PersonMapper.selectPersonById', {'id': 1});
final count = await session.insert('PersonMapper.insertPerson', personData);
Constructors
-
SqlSession(Database _database, Map<
String, SqlStatement> _statements) - Creates a session over database with the given statements.
Properties
- database → Database
-
The underlying database.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
batchInsert(
String statementId, List< Map< paramsList) → Future<String, dynamic> >List< int> > - Inserts many rows in a single transaction.
-
delete(
String statementId, Map< String, dynamic> params) → Future<int> -
Runs a
<delete>. -
hasStatement(
String statementId) → bool -
Whether
statementIdis registered. -
insert(
String statementId, Map< String, dynamic> params) → Future<int> -
Runs an
<insert>. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
selectCount(
String statementId, Map< String, dynamic> params, {String countColumn = 'CNT'}) → Future<int> -
Runs a COUNT
<select>and returns the number. -
selectList(
String statementId, Map< String, dynamic> params, {int? limit, int? offset}) → Future<List< Map< >String, dynamic> > -
Runs a
<select>and returns every row. -
selectOne(
String statementId, Map< String, dynamic> params) → Future<Map< String, dynamic> ?> -
Runs a
<select>and returns the first row. -
toString(
) → String -
A string representation of this object.
inherited
-
transaction<
T> (Future< T> action(SqlSession txSession)) → Future<T> -
Runs
actioninside a transaction. -
update(
String statementId, Map< String, dynamic> params) → Future<int> -
Runs an
<update>.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited