-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 -Considerations on the 2017 Java Persistence Framework (5) Iciql -Discussion on Java Persistence Framework for 2017 (6) Ebean
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 automatic generation of entities. --The EntityManager specification seems to be a roundabout when used in a containerless environment. --I forgot until I used persistence.xml --JPA 2.0 uses annotation processing to generate metamodels, type safe, column name change resistance, etc. are powered up ―― …… Isn't it dull compared to metamodels and other ORM libraries? --EclipseLink 2.7.0 javax.persistence error due to incorrect signature, why, after all, avoid the mystery of inserting javax.persistence 2.1.1
Main.java
CriteriaQuery<Employee> query = em.getCriteriaBuilder().createQuery(Employee.class);
em.createQuery(query).getResultStream().forEach(e -> {
System.out.format("%1s: %2s, %3s, %4s\n", e.id, e.first_name, e.middle_name, e.last_name);
});
Main.java
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Employee> query = builder.createQuery(Employee.class);
Root<Employee> root = query.from(Employee.class);
em.createQuery(query.select(root).where(builder.equal(root.get(Employee_.id), 1L)))
.getResultStream()
.forEach(e -> {
System.out.format("%1s: %2s, %3s, %4s\n", e.id, e.first_name, e.middle_name, e.last_name);
});
Main.java
em.createQuery(query.select(root).where(builder.equal(root.get(Employee_.id), 1L)))
.getResultStream()
.forEach(e -> {
System.out.format("%1s: %2s, %3s, %4s\n", e.id, e.first_name, e.middle_name, e.last_name);
e.posts.stream().forEach(p -> {
System.out.format("\t%1s: %2s, %3s\n", p.id, p.employee_id, p.name);
});
});
Employee.java
@Entity
@Table(name="employee")
public class Employee {
@Id
public long id;
public String first_name;
public String middle_name;
public String last_name;
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "employee_id", table = "post")
public List<Post> posts;
}
Post.java
@Entity
@Table(name="post")
public class Post {
@Id
public long id;
public long employee_id;
public String name;
}
--JPA reference implementation, so JPA
--When you build using EclipseLink 2.7.0 normally, you get angry that "javax.persistence signature is different". -Bug 525457 Seriously Kayo Jotaro
Is not yet.
-JPA Mapping Catalog -JavaEE Usage Memo (JPA Part 4-Criteria API)
Recommended Posts