Application Development with MariaDB/Connector/R2DBC (Spring Data)
Overview
Building Applications
Build the package:
$ mvn package$ java -jar target/app.jarCode Example: Create an Entity
// Imports the @Id annotation type, which demarcates an identifier.
import org.springframework.data.annotation.Id;
// This is an Entity class
// It has the same name as the text.contact table
public class Contact {
// The class members correspond to columns
// in the test.contact table
private int id;
private String first_name;
private String last_name;
private String email;
// Constructor
public Contact(int id, String first_name, String last_name, String email) {
this.id = id;
this.first_name = first_name;
this.last_name = last_name;
this.email = email;
}
// The @Id annotation indicates that this field
// is the primary key column
@Id
public int getId() {
return id;
}
public String getFirst_name() {
return first_name;
}
public String getLast_name() {
return last_name;
}
public String getEmail() {
return email;
}
@Override
public String toString() {
return "Contact [id=" + id + ", first_name=" + first_name + ", last_name=" + last_name + ", email=" + email + "]";
}
}PreviousUsing the Spring Data Framework with MariaDB Connector/R2DBCNextBatch Operations with MariaDB Connector/R2DBC (Spring Data)
Last updated
Was this helpful?

