@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
 /* 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;
 }