Package com.jcasey.model

Examples of com.jcasey.model.Book


    return "success";
  }
 
  public String execute()
  {
    Book book = controller.getBook(getBookId());
   
    if(book !=  null)
    {
      this.author = book.getAuthor();
      this.title = book.getTitle();

      bookGenre = book.getBookGenre();
     
      for(BookGenre data: bookGenre)
      {
        genre = genre + data.getGenre().getGenre() + ",";
      }
     
      this.blurb = book.getBlurb();
      this.isbn = book.getIsbn();
     
      return "update";
    }
    else
    {
View Full Code Here


    return "success";
  }
 
  public String execute()
  {
    Book book = linkController.get(getBookId());
   
    if(book !=  null)
    {
      this.author = book.getAuthor();
      this.title = book.getTitle();
      this.genre = book.getGenre();
      this.blurb = book.getBlurb();
      this.isbn = book.getIsbn();
     
      return "update";
    }
    else
    {
View Full Code Here

  public void testAuditRecords()
  {
    Manager manager = new Manager();

    // create book record
    Book book = new Book();
    book.setTitle("Gone with the wind");
   
    book = manager.addBook(book);
   
    book.setAuthor("Margaret Mitchell");
    book = manager.update(book);
   
    book.setTitle("Gone With The Wind");
    book = manager.update(book);
   
    manager.deleteBook(book.getBookId());
   
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    AuditReader auditReader = AuditReaderFactory.get(session);
    AuditQuery query = auditReader.createQuery().forRevisionsOfEntity(Book.class, false /* complete revision data: if true just return Book objects */, true /* return deleted entities */).add(new IdentifierEqAuditExpression(book.getBookId(), true));
   
    List<Object[]> bookRevisions = query.getResultList();
   
    assertTrue("The entity does not have 4 revision records",bookRevisions.size() == 4);
   
    for(Object[] auditData : bookRevisions)
    {
      Book oldBook = (Book) auditData[0];
     
      System.out.print(oldBook);
     
      DefaultRevisionEntity revData = (DefaultRevisionEntity) auditData[1];
     
View Full Code Here

  public void testOptimisticLocking()
  {
    Manager manager = new Manager();

    // create book record
    Book book1 = new Book();
    book1.setTitle("Gone");

    // persist
    book1 = manager.addBook(book1);

    // update the title in memory
    book1.setTitle("Gone with the wind");
   
    // load original record
    Book book2 = manager.getBook(book1.getBookId());
   
    // update the title in memory
    book2.setTitle("Test");

    // persist book2
    manager.update(book2);

    // attempt to persist out of date book1
View Full Code Here

    return book;
  }
  public Book delete(Long id) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
    Book book = (Book) session.load(Book.class, id);
    if(null != book) {
      session.delete(book);
    }
    session.getTransaction().commit();
    return book;
View Full Code Here

  }
 
  public Book deleteBook(Long id) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
    Book book = (Book) session.load(Book.class, id);
    if(null != book) {
      session.delete(book);
    }
    session.getTransaction().commit();
    return book;
View Full Code Here

TOP

Related Classes of com.jcasey.model.Book

Copyright © 2018 www.massapicom. 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.