or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

authentication.mdconfiguration.mdexceptions.mdindex.mdinterceptors.mdjdbc-advanced.mdjdbc-core.mdjdbc-high-availability.mdlogging-monitoring.mdtype-system.mdutilities.mdxdevapi-core.mdxdevapi-crud.mdxdevapi-sql.md

xdevapi-crud.mddocs/

0

# X DevAPI CRUD Operations

1

2

Fluent statement builders for Create, Read, Update, and Delete operations on collections and tables. These interfaces provide a chainable API for building complex queries and modifications.

3

4

## Capabilities

5

6

### Statement Base Interface

7

8

The base interface for all X DevAPI statements, providing common functionality for execution and parameter binding.

9

10

```java { .api }

11

package com.mysql.cj.xdevapi;

12

13

import java.util.List;

14

import java.util.Map;

15

import java.util.concurrent.CompletableFuture;

16

17

public interface Statement<STMT_T, RES_T> {

18

// Lock contention options

19

enum LockContention {

20

DEFAULT, // Wait until the row lock is released

21

NOWAIT, // Do not wait to acquire row lock; fail with error if locked

22

SKIP_LOCKED; // Do not wait; remove locked rows from result set

23

}

24

25

// Synchronous execution

26

RES_T execute();

27

28

// Asynchronous execution

29

CompletableFuture<RES_T> executeAsync();

30

31

// Parameter binding

32

// Note: Some bind methods have default implementations that throw UnsupportedOperationException

33

// for statements that don't support parameter binding. Check specific statement implementations.

34

STMT_T clearBindings();

35

STMT_T bind(String argName, Object value);

36

STMT_T bind(Map<String, Object> values);

37

STMT_T bind(List<Object> values);

38

STMT_T bind(Object... values);

39

}

40

```

41

42

Usage:

43

44

```java

45

// Asynchronous execution

46

CompletableFuture<DocResult> futureResult = collection.find("age > :minAge")

47

.bind("minAge", 18)

48

.executeAsync();

49

50

futureResult.thenAccept(result -> {

51

while (result.hasNext()) {

52

DbDoc doc = result.next();

53

System.out.println(doc.toString());

54

}

55

});

56

57

// Multiple parameter binding approaches

58

FindStatement stmt = collection.find("name = :name AND age = :age");

59

60

// Bind individually

61

stmt.bind("name", "Alice").bind("age", 30);

62

63

// Bind with map

64

Map<String, Object> params = new HashMap<>();

65

params.put("name", "Alice");

66

params.put("age", 30);

67

stmt.bind(params).execute();

68

69

// Bind with list (positional binding with indices)

70

stmt.bind(Arrays.asList("Alice", 30)).execute();

71

72

// Bind with varargs

73

stmt.bind("Alice", 30).execute();

74

```

75

76

### Add Statement (Collection)

77

78

Statement for adding documents to a collection.

79

80

```java { .api }

81

package com.mysql.cj.xdevapi;

82

83

public interface AddStatement extends Statement<AddStatement, AddResult> {

84

// Add documents

85

AddStatement add(String jsonString);

86

AddStatement add(DbDoc... docs);

87

AddStatement add(String... jsonStrings);

88

AddStatement add(Map<String, ?> docMap);

89

90

// Upsert support (used internally by Collection.addOrReplaceOne)

91

boolean isUpsert();

92

AddStatement setUpsert(boolean upsert);

93

94

// Execute statement

95

AddResult execute();

96

}

97

98

public class AddStatementImpl extends FilterableStatement<AddStatement, AddResult>

99

implements AddStatement {

100

// Implementation

101

102

public AddStatement add(DbDoc... docs);

103

public AddStatement add(String... jsonStrings);

104

public AddStatement add(Map<String, ?> docMap);

105

public AddResult execute();

106

}

107

108

public interface AddResult extends Result {

109

// Get generated document IDs

110

List<String> getGeneratedIds();

111

112

// Get affected items count

113

long getAffectedItemsCount();

114

115

// Get warnings

116

int getWarningsCount();

117

Iterator<Warning> getWarnings();

118

}

119

120

public class AddResultImpl implements AddResult {

121

public List<String> getGeneratedIds();

122

public long getAffectedItemsCount();

123

public int getWarningsCount();

124

public Iterator<Warning> getWarnings();

125

}

126

```

127

128

Usage:

129

130

```java

131

Collection users = schema.getCollection("users");

132

133

// Add single document

134

AddResult result = users.add("{\"name\": \"Alice\", \"age\": 30}").execute();

135

System.out.println("Generated IDs: " + result.getGeneratedIds());

136

137

// Add multiple documents

138

DbDoc doc1 = users.newDoc().add("name", new JsonString().setValue("Bob")).add("age", new JsonNumber().setValue("25"));

139

DbDoc doc2 = users.newDoc().add("name", new JsonString().setValue("Charlie")).add("age", new JsonNumber().setValue("35"));

140

AddResult result2 = users.add(doc1, doc2).execute();

141

142

// Add from map

143

Map<String, Object> userMap = new HashMap<>();

144

userMap.put("name", "David");

145

userMap.put("age", 28);

146

users.add(userMap).execute();

147

```

148

149

### Find Statement (Collection)

150

151

Statement for finding documents in a collection.

152

153

```java { .api }

154

package com.mysql.cj.xdevapi;

155

156

public interface FindStatement extends Statement<FindStatement, DocResult> {

157

// Projection

158

FindStatement fields(String... projection);

159

FindStatement fields(Expression projection);

160

161

// Grouping

162

FindStatement groupBy(String... fields);

163

FindStatement having(String having);

164

165

// Ordering

166

FindStatement orderBy(String... sortFields);

167

FindStatement sort(String... sortFields);

168

169

// Limiting

170

FindStatement limit(long numberOfRows);

171

FindStatement offset(long numberOfRows);

172

173

/**

174

* @deprecated Deprecated in Connector/J 8.0.12, use {@link #offset(long)} instead.

175

*/

176

@Deprecated

177

default FindStatement skip(long limitOffset) {

178

return offset(limitOffset);

179

}

180

181

// Locking

182

FindStatement lockShared();

183

FindStatement lockShared(Statement.LockContention lockContention);

184

FindStatement lockExclusive();

185

FindStatement lockExclusive(Statement.LockContention lockContention);

186

187

// Binding

188

FindStatement bind(String name, Object value);

189

FindStatement bind(Map<String, Object> values);

190

191

// Execution

192

DocResult execute();

193

}

194

195

public class FindStatementImpl extends FilterableStatement<FindStatement, DocResult>

196

implements FindStatement {

197

public FindStatement fields(String... projection);

198

public FindStatement fields(Expression projection);

199

public FindStatement groupBy(String... fields);

200

public FindStatement having(String having);

201

public FindStatement orderBy(String... sortFields);

202

public FindStatement sort(String... sortFields);

203

public FindStatement limit(long numberOfRows);

204

public FindStatement offset(long numberOfRows);

205

public FindStatement lockShared();

206

public FindStatement lockShared(Statement.LockContention lockContention);

207

public FindStatement lockExclusive();

208

public FindStatement lockExclusive(Statement.LockContention lockContention);

209

public FindStatement bind(String name, Object value);

210

public FindStatement bind(Map<String, Object> values);

211

public DocResult execute();

212

}

213

214

public interface DocResult extends FetchResult<DbDoc>, Iterator<DbDoc> {

215

// Iteration

216

boolean hasNext();

217

DbDoc next();

218

219

// Fetch operations

220

DbDoc fetchOne();

221

List<DbDoc> fetchAll();

222

int count();

223

224

// Warnings

225

int getWarningsCount();

226

Iterator<Warning> getWarnings();

227

}

228

229

public class DocResultImpl implements DocResult {

230

public boolean hasNext();

231

public DbDoc next();

232

public DbDoc fetchOne();

233

public List<DbDoc> fetchAll();

234

public int count();

235

public int getWarningsCount();

236

public Iterator<Warning> getWarnings();

237

}

238

```

239

240

Usage:

241

242

```java

243

Collection users = schema.getCollection("users");

244

245

// Simple find

246

DocResult result = users.find().execute();

247

while (result.hasNext()) {

248

DbDoc doc = result.next();

249

System.out.println(doc.toString());

250

}

251

252

// Find with condition

253

DocResult result2 = users.find("age > :minAge")

254

.bind("minAge", 25)

255

.execute();

256

257

// Find with projection

258

DocResult result3 = users.find("age > 25")

259

.fields("name", "age")

260

.execute();

261

262

// Find with ordering and limiting

263

DocResult result4 = users.find()

264

.orderBy("age DESC")

265

.limit(10)

266

.execute();

267

268

// Find with grouping

269

DocResult result5 = users.find()

270

.fields("age", "COUNT(*) as count")

271

.groupBy("age")

272

.having("count > 1")

273

.execute();

274

275

// Find with locking

276

session.startTransaction();

277

DocResult result6 = users.find("_id = :id")

278

.bind("id", "someId")

279

.lockExclusive()

280

.execute();

281

// Modify locked document

282

session.commit();

283

284

// Fetch all at once

285

List<DbDoc> allDocs = users.find().execute().fetchAll();

286

```

287

288

### Modify Statement (Collection)

289

290

Statement for modifying documents in a collection.

291

292

```java { .api }

293

package com.mysql.cj.xdevapi;

294

295

public interface ModifyStatement extends Statement<ModifyStatement, Result> {

296

// Modification operations

297

ModifyStatement set(String docPath, Object value);

298

ModifyStatement change(String docPath, Object value);

299

ModifyStatement unset(String... fields);

300

ModifyStatement arrayInsert(String docPath, Object value);

301

ModifyStatement arrayAppend(String docPath, Object value);

302

ModifyStatement patch(DbDoc patch);

303

ModifyStatement patch(String jsonPatch);

304

305

// Ordering and limiting

306

ModifyStatement sort(String... sortFields);

307

ModifyStatement limit(long numberOfRows);

308

309

// Binding

310

ModifyStatement bind(String name, Object value);

311

ModifyStatement bind(Map<String, Object> values);

312

313

// Execution

314

Result execute();

315

}

316

317

public class ModifyStatementImpl extends FilterableStatement<ModifyStatement, Result>

318

implements ModifyStatement {

319

public ModifyStatement set(String docPath, Object value);

320

public ModifyStatement change(String docPath, Object value);

321

public ModifyStatement unset(String... fields);

322

public ModifyStatement arrayInsert(String docPath, Object value);

323

public ModifyStatement arrayAppend(String docPath, Object value);

324

public ModifyStatement patch(DbDoc patch);

325

public ModifyStatement patch(String jsonPatch);

326

public ModifyStatement sort(String... sortFields);

327

public ModifyStatement limit(long numberOfRows);

328

public ModifyStatement bind(String name, Object value);

329

public ModifyStatement bind(Map<String, Object> values);

330

public Result execute();

331

}

332

333

public enum UpdateType {

334

SET,

335

ITEM_REMOVE,

336

ITEM_SET,

337

ITEM_REPLACE,

338

ITEM_MERGE,

339

ARRAY_INSERT,

340

ARRAY_APPEND,

341

MERGE_PATCH;

342

}

343

344

public class UpdateSpec {

345

public UpdateSpec(UpdateType type, String path);

346

public UpdateSpec setValue(Object value);

347

public UpdateType getUpdateType();

348

public String getSource();

349

public Object getValue();

350

}

351

```

352

353

Usage:

354

355

```java

356

Collection users = schema.getCollection("users");

357

358

// Set field value

359

users.modify("_id = :id")

360

.set("age", 31)

361

.bind("id", "someId")

362

.execute();

363

364

// Unset field

365

users.modify("_id = :id")

366

.unset("middleName")

367

.bind("id", "someId")

368

.execute();

369

370

// Change field value (only if it exists)

371

users.modify("age > 25")

372

.change("status", "active")

373

.execute();

374

375

// Array operations

376

users.modify("_id = :id")

377

.arrayAppend("hobbies", "reading")

378

.bind("id", "someId")

379

.execute();

380

381

users.modify("_id = :id")

382

.arrayInsert("hobbies[0]", "coding")

383

.bind("id", "someId")

384

.execute();

385

386

// Patch document

387

DbDoc patch = new DbDocImpl();

388

patch.add("age", new JsonNumber().setValue("32"));

389

patch.add("city", new JsonString().setValue("New York"));

390

users.modify("_id = :id")

391

.patch(patch)

392

.bind("id", "someId")

393

.execute();

394

395

// Multiple modifications

396

users.modify("age > :minAge")

397

.set("status", "verified")

398

.set("lastUpdated", Expression.expr("NOW()"))

399

.bind("minAge", 18)

400

.limit(100)

401

.execute();

402

403

// Use expression

404

users.modify("_id = :id")

405

.set("visits", Expression.expr("visits + 1"))

406

.bind("id", "someId")

407

.execute();

408

```

409

410

### Remove Statement (Collection)

411

412

Statement for removing documents from a collection.

413

414

```java { .api }

415

package com.mysql.cj.xdevapi;

416

417

public interface RemoveStatement extends Statement<RemoveStatement, Result> {

418

// Ordering and limiting

419

RemoveStatement sort(String... sortFields);

420

RemoveStatement limit(long numberOfRows);

421

422

// Binding

423

RemoveStatement bind(String name, Object value);

424

RemoveStatement bind(Map<String, Object> values);

425

426

// Execution

427

Result execute();

428

}

429

430

public class RemoveStatementImpl extends FilterableStatement<RemoveStatement, Result>

431

implements RemoveStatement {

432

public RemoveStatement sort(String... sortFields);

433

public RemoveStatement limit(long numberOfRows);

434

public RemoveStatement bind(String name, Object value);

435

public RemoveStatement bind(Map<String, Object> values);

436

public Result execute();

437

}

438

439

public interface Result {

440

long getAffectedItemsCount();

441

int getWarningsCount();

442

Iterator<Warning> getWarnings();

443

}

444

```

445

446

Usage:

447

448

```java

449

Collection users = schema.getCollection("users");

450

451

// Remove with condition

452

Result result = users.remove("age < :minAge")

453

.bind("minAge", 18)

454

.execute();

455

System.out.println("Removed: " + result.getAffectedItemsCount());

456

457

// Remove with limit

458

users.remove("status = 'inactive'")

459

.limit(10)

460

.execute();

461

462

// Remove with sorting

463

users.remove("age > 65")

464

.sort("age DESC")

465

.limit(5)

466

.execute();

467

468

// Remove all matching

469

users.remove("verified = false").execute();

470

```

471

472

### Insert Statement (Table)

473

474

Statement for inserting rows into a table.

475

476

```java { .api }

477

package com.mysql.cj.xdevapi;

478

479

public interface InsertStatement extends Statement<InsertStatement, InsertResult> {

480

// Add values

481

InsertStatement values(Object... values);

482

InsertStatement values(List<Object> values);

483

484

// Execution

485

InsertResult execute();

486

}

487

488

public class InsertStatementImpl implements InsertStatement {

489

public InsertStatement values(Object... values);

490

public InsertStatement values(List<Object> values);

491

public InsertResult execute();

492

}

493

494

public interface InsertResult extends Result {

495

Long getAutoIncrementValue();

496

long getAffectedItemsCount();

497

int getWarningsCount();

498

Iterator<Warning> getWarnings();

499

}

500

501

public class InsertResultImpl implements InsertResult {

502

public Long getAutoIncrementValue();

503

public long getAffectedItemsCount();

504

public int getWarningsCount();

505

public Iterator<Warning> getWarnings();

506

}

507

508

public class InsertParams {

509

// Helper class for collecting insert parameters

510

public InsertParams(List<String> fields);

511

public void addRow(List<Object> row);

512

public List<String> getFields();

513

public List<List<Object>> getRows();

514

}

515

```

516

517

Usage:

518

519

```java

520

Table employees = schema.getTable("employees");

521

522

// Insert single row

523

InsertResult result = employees.insert("name", "age", "department")

524

.values("Alice", 30, "Engineering")

525

.execute();

526

System.out.println("Auto-increment ID: " + result.getAutoIncrementValue());

527

528

// Insert multiple rows

529

employees.insert("name", "age", "department")

530

.values("Bob", 25, "Sales")

531

.values("Charlie", 35, "Marketing")

532

.values("David", 28, "Engineering")

533

.execute();

534

535

// Insert with nulls

536

employees.insert("name", "age", "department")

537

.values("Eve", 32, null)

538

.execute();

539

540

// Insert from list

541

List<Object> row = Arrays.asList("Frank", 29, "IT");

542

employees.insert("name", "age", "department")

543

.values(row)

544

.execute();

545

```

546

547

### Select Statement (Table)

548

549

Statement for selecting rows from a table.

550

551

```java { .api }

552

package com.mysql.cj.xdevapi;

553

554

public interface SelectStatement extends Statement<SelectStatement, RowResult> {

555

// Filtering

556

SelectStatement where(String searchCondition);

557

558

// Grouping

559

SelectStatement groupBy(String... fields);

560

SelectStatement having(String having);

561

562

// Ordering

563

SelectStatement orderBy(String... sortFields);

564

565

// Limiting

566

SelectStatement limit(long numberOfRows);

567

SelectStatement offset(long numberOfRows);

568

569

// Locking

570

SelectStatement lockShared();

571

SelectStatement lockShared(Statement.LockContention lockContention);

572

SelectStatement lockExclusive();

573

SelectStatement lockExclusive(Statement.LockContention lockContention);

574

575

// Binding

576

SelectStatement bind(String name, Object value);

577

SelectStatement bind(Map<String, Object> values);

578

579

// Execution

580

RowResult execute();

581

582

// Filter parameters (internal use)

583

FilterParams getFilterParams();

584

}

585

586

public class SelectStatementImpl implements SelectStatement {

587

public SelectStatement where(String searchCondition);

588

public SelectStatement groupBy(String... fields);

589

public SelectStatement having(String having);

590

public SelectStatement orderBy(String... sortFields);

591

public SelectStatement limit(long numberOfRows);

592

public SelectStatement offset(long numberOfRows);

593

public SelectStatement lockShared();

594

public SelectStatement lockShared(Statement.LockContention lockContention);

595

public SelectStatement lockExclusive();

596

public SelectStatement lockExclusive(Statement.LockContention lockContention);

597

public SelectStatement bind(String name, Object value);

598

public SelectStatement bind(Map<String, Object> values);

599

public RowResult execute();

600

}

601

602

public interface RowResult extends FetchResult<Row>, Iterator<Row> {

603

// Iteration

604

boolean hasNext();

605

Row next();

606

607

// Fetch operations

608

Row fetchOne();

609

List<Row> fetchAll();

610

int count();

611

612

// Metadata

613

int getColumnCount();

614

List<Column> getColumns();

615

List<String> getColumnNames();

616

617

// Warnings

618

int getWarningsCount();

619

Iterator<Warning> getWarnings();

620

}

621

622

public class RowResultImpl implements RowResult {

623

public boolean hasNext();

624

public Row next();

625

public Row fetchOne();

626

public List<Row> fetchAll();

627

public int count();

628

public int getColumnCount();

629

public List<Column> getColumns();

630

public List<String> getColumnNames();

631

public int getWarningsCount();

632

public Iterator<Warning> getWarnings();

633

}

634

```

635

636

Usage:

637

638

```java

639

Table employees = schema.getTable("employees");

640

641

// Simple select

642

RowResult result = employees.select("name", "age", "department").execute();

643

while (result.hasNext()) {

644

Row row = result.next();

645

System.out.println(row.getString("name") + " - " + row.getInt("age"));

646

}

647

648

// Select with condition

649

RowResult result2 = employees.select("*")

650

.where("age > :minAge AND department = :dept")

651

.bind("minAge", 25)

652

.bind("dept", "Engineering")

653

.execute();

654

655

// Select with ordering and limiting

656

RowResult result3 = employees.select("name", "salary")

657

.where("department = 'Sales'")

658

.orderBy("salary DESC")

659

.limit(10)

660

.execute();

661

662

// Select with grouping

663

RowResult result4 = employees.select("department", "COUNT(*) as count", "AVG(salary) as avg_salary")

664

.groupBy("department")

665

.having("count > 5")

666

.execute();

667

668

// Select with offset

669

RowResult result5 = employees.select("*")

670

.orderBy("id")

671

.limit(20)

672

.offset(40) // Skip first 40 rows

673

.execute();

674

675

// Get column metadata

676

List<Column> columns = result.getColumns();

677

for (Column col : columns) {

678

System.out.println(col.getColumnName() + " - " + col.getType());

679

}

680

```

681

682

### Update Statement (Table)

683

684

Statement for updating rows in a table.

685

686

```java { .api }

687

package com.mysql.cj.xdevapi;

688

689

public interface UpdateStatement extends Statement<UpdateStatement, Result> {

690

// Set field values

691

UpdateStatement set(String field, Object value);

692

693

// Filtering

694

UpdateStatement where(String searchCondition);

695

696

// Ordering and limiting

697

UpdateStatement orderBy(String... sortFields);

698

UpdateStatement limit(long numberOfRows);

699

700

// Binding

701

UpdateStatement bind(String name, Object value);

702

UpdateStatement bind(Map<String, Object> values);

703

704

// Execution

705

Result execute();

706

}

707

708

public class UpdateStatementImpl implements UpdateStatement {

709

public UpdateStatement set(String field, Object value);

710

public UpdateStatement where(String searchCondition);

711

public UpdateStatement orderBy(String... sortFields);

712

public UpdateStatement limit(long numberOfRows);

713

public UpdateStatement bind(String name, Object value);

714

public UpdateStatement bind(Map<String, Object> values);

715

public Result execute();

716

}

717

718

public class UpdateParams {

719

// Helper class for collecting update parameters

720

public UpdateParams();

721

public void addField(String field, Object value);

722

public Map<String, Object> getFields();

723

}

724

725

public class UpdateResult implements Result {

726

public long getAffectedItemsCount();

727

public int getWarningsCount();

728

public Iterator<Warning> getWarnings();

729

}

730

```

731

732

Usage:

733

734

```java

735

Table employees = schema.getTable("employees");

736

737

// Update with condition

738

Result result = employees.update()

739

.set("salary", 55000)

740

.where("name = :name")

741

.bind("name", "Alice")

742

.execute();

743

System.out.println("Updated: " + result.getAffectedItemsCount());

744

745

// Update multiple fields

746

employees.update()

747

.set("salary", 60000)

748

.set("department", "Senior Engineering")

749

.where("age > :minAge AND department = :dept")

750

.bind("minAge", 30)

751

.bind("dept", "Engineering")

752

.execute();

753

754

// Update with limit

755

employees.update()

756

.set("bonus", 1000)

757

.where("performance = 'excellent'")

758

.limit(10)

759

.execute();

760

761

// Update with expression

762

employees.update()

763

.set("salary", Expression.expr("salary * 1.1"))

764

.where("department = 'Sales'")

765

.execute();

766

```

767

768

### Delete Statement (Table)

769

770

Statement for deleting rows from a table.

771

772

```java { .api }

773

package com.mysql.cj.xdevapi;

774

775

public interface DeleteStatement extends Statement<DeleteStatement, Result> {

776

// Filtering

777

DeleteStatement where(String searchCondition);

778

779

// Ordering and limiting

780

DeleteStatement orderBy(String... sortFields);

781

DeleteStatement limit(long numberOfRows);

782

783

// Binding

784

DeleteStatement bind(String name, Object value);

785

DeleteStatement bind(Map<String, Object> values);

786

787

// Execution

788

Result execute();

789

}

790

791

public class DeleteStatementImpl implements DeleteStatement {

792

public DeleteStatement where(String searchCondition);

793

public DeleteStatement orderBy(String... sortFields);

794

public DeleteStatement limit(long numberOfRows);

795

public DeleteStatement bind(String name, Object value);

796

public DeleteStatement bind(Map<String, Object> values);

797

public Result execute();

798

}

799

```

800

801

Usage:

802

803

```java

804

Table employees = schema.getTable("employees");

805

806

// Delete with condition

807

Result result = employees.delete()

808

.where("age > :maxAge")

809

.bind("maxAge", 65)

810

.execute();

811

System.out.println("Deleted: " + result.getAffectedItemsCount());

812

813

// Delete with limit

814

employees.delete()

815

.where("status = 'inactive'")

816

.limit(10)

817

.execute();

818

819

// Delete with ordering

820

employees.delete()

821

.where("department = 'Sales'")

822

.orderBy("hire_date")

823

.limit(5)

824

.execute();

825

826

// Delete all matching

827

employees.delete()

828

.where("terminated = true")

829

.execute();

830

```

831

832

### Base Statement Interfaces

833

834

Base interfaces for statement building.

835

836

```java { .api }

837

package com.mysql.cj.xdevapi;

838

839

public interface Statement<STMT_T, RES_T> {

840

// Execute statement

841

RES_T execute();

842

}

843

844

public interface FetchResult<T> {

845

// Fetch operations

846

T fetchOne();

847

List<T> fetchAll();

848

int count();

849

}

850

851

/**

852

* Lock contention options defined as a nested enum in the Statement interface.

853

* Use as Statement.LockContention.DEFAULT, Statement.LockContention.NOWAIT, etc.

854

*/

855

public static enum Statement.LockContention {

856

DEFAULT, // Wait until the row lock is released

857

NOWAIT, // Fail with error if row is locked

858

SKIP_LOCKED // Remove locked rows from result set

859

}

860

```

861

862

### Filterable Statement

863

864

Abstract base class for statements with filtering capabilities.

865

866

```java { .api }

867

package com.mysql.cj.xdevapi;

868

869

public abstract class FilterableStatement<STMT_T, RES_T> implements Statement<STMT_T, RES_T> {

870

// Subclasses implement specific filtering logic

871

}

872

873

public abstract class PreparableStatement<RES_T> {

874

// Base class for statements that can be prepared

875

// (Future enhancement for prepared statement support)

876

}

877

```

878