-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
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."
ORM | Transaction | Data Model | DSL |
---|---|---|---|
○ | × | × | ○ |
○: Correspondence ×: Not supported
―― "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
-
--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
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);
});
}
}
Main.java
List<Employee> list = db.from(e).where(e.id).is(BigDecimal.ONE).select();
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() {}
}
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() {
}
}
--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
Believe in the source as the official documentation is different.
Is not yet.
Recommended Posts