@Test
  public void test() {

    doInJPA(
        entityManager -> {
          Post post = new Post();
          post.setId(1L);
          post.setTitle("High-Performance Java Persistence");
          entityManager.persist(post);
        });
    doInJPA(
        entityManager -> {
          Post post = entityManager.find(Post.class, 1L);
          LOGGER.info("Fetched post: {}", post);
          post.setScore(12);
        });
  }
コード例 #2
0
ファイル: User.java プロジェクト: astolarz/OpenBook
 public List<Post> news() {
   return Post.find(
           "SELECT p FROM Post p, IN(p.author.friendedBy) u WHERE u.from.id = ?1 and (U.accepted = true or u.to.id = ?1) order by p.updatedAt desc",
           this.id)
       .fetch();
 }
コード例 #3
0
ファイル: Post.java プロジェクト: pengguo/Dary-The-Blog
 /* Checks if a comment belongs to this Post or to its root post
 RECURSIVE untill no rootPost encountered
 invoced in blog.scala.html */
 public boolean belongsToComment(Comment c) {
   if (c.post.equals(this)) return true;
   if (rootPost == null) return false;
   if (rootPost.belongsToComment(c)) return true;
   return false;
 }