Consideration on Java Persistence Framework 2017 (5) Iciql

Correction history

  1. 2017/11/14 The title was changed to "Framework" instead of the interesting name "Persistent Frame".

Previous post

-Discussion on Java Persistence Framework for 2017 (1) -Consideration of 2017 Java Persistence Framework (2) Doma2 -Guessing about the 2017 Java Persistence Framework (3) Reladomo -Discussion on Java Persistence Framework for 2017 (4) jOOQ

Preface

Since I am writing using the gap time, I would appreciate it if you could point out any parts with poor accuracy. First, exclude those that are EOL. We will consider paid functions, but we will not actually use them, due to the problem of pockets. The DB used is fixed to Postgre for a stupid reason such as "Well, maybe Postgre can be used even if it is not specified."

environment

Table structure

employeeテーブルからpostテーブルにID紐づけ

Correspondence range

ORM Transaction Data Model DSL
× ×

○: Correspondence ×: Not supported

Impressions

―― "There is no powerful DSL function like jOOQ and QueryDSL, and it is not an enterprise ORM like Hibernate or mybatis." --Oh, the document is old -Capture.PNG --How to execute the data model creation tool --Error: java -cp iciql.jar; your_db_driver.jar <parameters> --Correct: java -cp iciql.jar; your_db_driver.jar com.iciql.util.GenerateModels <parameters> --Parameters --Wrong: -username --Correct: -user --Wrong: -Folder --Correct: -folder --Suddenly out of support for postgre character type (described later) --Something, or data model, is created based on annotation by POJO ――There is also a generation tool, but it's just a level of assistance ――Plenty of push in exchange for freedom

sample

Single table search

Search all

Main.java


public static void main(String... args) {
    try (Db db = Db.open("jdbc:postgresql:example", "postgres", "pass")) {
        Employee e = new Employee();
        List<Employee> list = db.from(e).select();

        list.stream().forEach(em -> {
            System.out.println(em.id + ":" + em.first_name + " " + em.middle_name + " " + em.last_name);
        });
    }
}

Primary key search

Main.java


List<Employee> list = db.from(e).where(e.id).is(BigDecimal.ONE).select();

Table join

Main.java


// 「com.iciql.IciqlException: ERROR:Column reference"id"Is ambiguous ", can you give me an identifier with join ...
//List<EmployeePost> list = db.from(e).innerJoin(p).on(p.employee_id).is(e.id).select();
EmployeePost[] list = db.open(EmployeePostDao.class).getAllEmployeePost();

Arrays.asList(list).stream().forEach(em -> {
    System.out.println(
        em.id + ":" + em.employee_id
            + "/" + em.first_name + " " + em.middle_name + " " + em.last_name + " " + em.name);
    });

EmployeePostDao.java


public interface EmployeePostDao extends Dao {
    //Somehow here only arrays and Lists are not allowed
    @SqlQuery("SELECT e.id AS employee_id, e.first_name, e.middle_name, e.last_name, p.id AS id, p.name FROM employee AS e INNER JOIN post AS p ON e.id = p.employee_id")
    EmployeePost[] getAllEmployeePost();
}

EmployeePost.java


@Iciql.IQSchema("public")
@Iciql.IQIndex(name="Id", type= Iciql.IndexType.UNIQUE, value={ "id" })
public class EmployeePost {

    @Iciql.IQColumn(primaryKey=true, nullable=false, defaultValue="0", name = "id")
    public BigDecimal id;
    public String first_name;
    public String last_name;
    public String middle_name;
    @Iciql.IQColumn(nullable=false, defaultValue="0")
    public BigDecimal employee_id;
    public String name;

    public EmployeePost() {}
}

Generated data model

Something really simple comes out. The column set by character (60) is unsupported by bpchar.

Employee.java


@IQSchema("public")
@IQTable(name="employee")
@IQIndex(name="Id", type=IndexType.UNIQUE, value={ "id" })
public class Employee implements Serializable {

	private static final long serialVersionUID = 1L;

	@IQColumn(primaryKey=true, nullable=false, defaultValue="0")
	public BigDecimal id;

	// unsupported type bpchar
	public Object first_name;

	// unsupported type bpchar
	public Object last_name;

	// unsupported type bpchar
	public Object middle_name;

	public Employee() {
	}
}

The point

--Providing only the minimum functions with an emphasis on the lightness of the library itself --POJO, interface-only definition, policy to eliminate all inheritance complexity

Addictive points

Believe in the source as the official documentation is different.

After post

Is not yet.

Reference article

Recommended Posts

Consideration on Java Persistence Framework 2017 (5) Iciql
Consideration on Java Persistence Framework 2017 (Summary) -1
Consideration on Java Persistence Framework 2017 (7) EclipseLink
Consideration on the 2017 Java Persistence Framework (1)
Consideration on Java Persistence Framework 2017 (8) Hibernate5
Consideration on Java Persistence Framework 2017 (2) Doma2
java framework
Guess about the 2017 Java Persistence Framework (3) Reladomo
Java framework comparison
[Java] Collection framework
Play Framework2.5 (Java) Tips
Let's touch on Java
Install Java on Mac
Run PostgreSQL on Java
[Development] Java framework comparison
Learning Java framework # 1 (Mac version)
Java version control on macOS
Install OpenJDK7 (JAVA) on ubuntu 14.04
Reflection on Java string manipulation
On passing Java Gold SE 8
Oracle Java 8 on Docker Ubuntu
Java Collections Framework Review Notes
Install Java on WSL Ubuntu 18.04
Run java applet on ubuntu
Put Oracle Java 8 on CircleCI 2
Java version change on CentOS
Install java 1.8.0 on Amazon linux2