Package com.apress.prospring3.springblog

Source Code of com.apress.prospring3.springblog.JpaCommentTest

/**
* Created on Oct 21, 2011
*/
package com.apress.prospring3.springblog;

import java.util.List;

import org.springframework.context.support.GenericXmlApplicationContext;

import com.apress.prospring3.springblog.domain.Comment;
import com.apress.prospring3.springblog.service.CommentService;

/**
* @author Clarence
*
*/
public class JpaCommentTest {

  /**
   * @param args
   */
  public static void main(String[] args) {

    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.load("classpath:jpa-app-context.xml");
    ctx.refresh();
   
    System.out.println("App context initialized successfully");
   
    CommentService commentService = ctx.getBean("commentService", CommentService.class);
   
    List<Comment> comments = commentService.findByEntryId(1l);
   
    System.out.println("No of comments: " + comments.size());
   
    for (Comment comment: comments) {
      System.out.println(comment.getPostBy());
    }
   
    List<String> replyTos = commentService.findReplyToByEntryId(3l);
   
    for (String replyTo: replyTos) {
      System.out.println(replyTo);
    }
  }

}
TOP

Related Classes of com.apress.prospring3.springblog.JpaCommentTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.