### Create New Person Record (Static) Source: https://javalite.io/activejdbc The shortest way to create a new Person record using a static 'createIt' method, passing attributes as key-value pairs. ```java Person.createIt("first_name", "Marilyn", "last_name", "Monroe", "dob", "1935-12-06"); ``` -------------------------------- ### Create New Person Record (Standard) Source: https://javalite.io/activejdbc Creates a new Person record by instantiating a Person object, setting its attributes, and then saving it to the database. ```java Person p = new Person(); p.set("first_name", "Marilyn"); p.set("last_name", "Monroe"); p.set("dob", "1935-12-06"); p.saveIt(); ``` -------------------------------- ### Create New Person Record (Chained) Source: https://javalite.io/activejdbc A more concise way to create a new Person record using method chaining for setting attributes before saving. ```java new Person().set("first_name", "Marilyn").set("last_name", "Monroe").set("dob", "1935-12-06").saveIt(); ``` -------------------------------- ### Maven Configuration for ActiveJDBC Instrumentation Source: https://javalite.io/activejdbc Configure the activejdbc-instrumentation plugin in your Maven pom.xml to process classes. Replace LATEST_VERSION with the actual latest version. ```xml org.javalite activejdbc-instrumentation LATEST_VERSION process-classes instrument ``` -------------------------------- ### Maven Repositories for Snapshots Source: https://javalite.io/activejdbc Add these repositories to your Maven pom.xml to access the latest snapshot versions of ActiveJDBC. Ensure snapshots are enabled and set an appropriate update policy. ```xml snapshots1 Sonatype Snapshots https://oss.sonatype.org/content/repositories/snapshots/ true always warn sonatype_plugin_snapshots Sonatype Plugin Snapshots https://oss.sonatype.org/content/repositories/snapshots/ true ``` -------------------------------- ### Paginated Employee Query Source: https://javalite.io/activejdbc Fetches a specific range of Employee records based on department and hire date, ordered by hire date. Supports database-specific optimizations. ```java List people = Employee.where("department = ? and hire_date > ? ", "IT", hireDate) .offset(21) .limit(10) .orderBy("hire_date asc"); ``` -------------------------------- ### Maven Dependency for ActiveJDBC Source: https://javalite.io/activejdbc Add this to your pom.xml to include the ActiveJDBC library. Replace LATEST_VERSION with the actual latest version from Maven Central. ```xml org.javalite activejdbc LATEST_VERSION ``` -------------------------------- ### Simple Person Query Source: https://javalite.io/activejdbc Retrieves all records from the 'people' table where the 'first_name' is 'John'. The result is a List of Person objects. ```java List people = Person.where("first_name = 'John'"); Person aJohn = people.get(0); String johnsLastName = aJohn.get("last_name"); ``` -------------------------------- ### MySQL DDL for People Table Source: https://javalite.io/activejdbc This is the MySQL Data Definition Language (DDL) statement used to create the 'people' table. It defines columns for ID, first name, last name, and timestamps. ```sql CREATE TABLE people ( id int(11) NOT NULL auto_increment PRIMARY KEY, first_name VARCHAR(56) NOT NULL, last_name VARCHAR(56), created_at DATETIME, updated_at DATETIME ); ``` -------------------------------- ### Update Employee Record Source: https://javalite.io/activejdbc Finds the first Employee record matching a condition and updates its 'last_name' attribute before saving the changes. ```java Employee e = Employee.findFirst("first_name = ?", "John"); e.set("last_name", "Steinbeck").saveIt(); ``` -------------------------------- ### Person Model Definition Source: https://javalite.io/activejdbc A simple Java class extending ActiveJDBC's Model. It automatically maps to a 'PEOPLE' table without explicit database schema configuration in the code. ```java public class Person extends Model {} ``` -------------------------------- ### Parametrized Person Query Source: https://javalite.io/activejdbc Retrieves records using a parametrized SQL query for safety and clarity. Replaces '?' placeholders with provided values. ```java List people = Person.where("first_name = ?", "John"); Person aJohn = people.get(0); String johnsLastName = aJohn.get("last_name"); ``` -------------------------------- ### Delete Employee Record Source: https://javalite.io/activejdbc Finds the first Employee record matching a condition and then deletes it from the database. ```java Employee e = Employee.findFirst("first_name = ?", "John"); e.delete(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.