Package org.conserve.objects

Examples of org.conserve.objects.Book


    asimov.setBirthYear(1920);
    asimov.setFirstName("Isaac");
    asimov.setLastName("Asimov");

    // create some books
    Book foundation = new Book("Foundation");
    foundation.setPublishedYear(1951);
    foundation.addKeyWord("science fiction");
    foundation.addKeyWord("psychohistory");
    asimov.addBook(foundation);
    Book cavesofsteel = new Book("The Caves of Steel");
    cavesofsteel.setPublishedYear(1954);
    cavesofsteel.addKeyWord("science fiction");
    cavesofsteel.addKeyWord("robot");
    cavesofsteel.addKeyWord("crime");
    asimov.addBook(cavesofsteel);

    // save everything
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    persist.saveObject(asimov);
    persist.close();

    // open a new connection
    persist = new PersistenceManager(driver, database, login, password);

    // find all books with the authors last name 'Asimov'.
    asimov = new Author();
    asimov.setLastName("Asimov");
    Book seekBook = new Book();
    seekBook.addAuthor(asimov);
    List<Book> asimovBooks = persist.getObjects(Book.class, new Equal(seekBook));
    assertEquals(2, asimovBooks.size());
    // print the title of the scifi books
    for (Book book : asimovBooks)
    {
View Full Code Here


    verne.setBirthYear(1828);
    verne.setFirstName("Jules");
    verne.setLastName("Verne");

    // create some books
    Book twocities = new Book("A Tale of Two Cities");
    twocities.setPublishedYear(1859);
    twocities.addKeyWord("London");
    twocities.addKeyWord("Paris");
    twocities.addKeyWord("revolution");
    dickens.addBook(twocities);
    Book olivertwist = new Book("Oliver Twist");
    olivertwist.setPublishedYear(1838);
    olivertwist.addKeyWord("crime");
    olivertwist.addKeyWord("London");
    dickens.addBook(olivertwist);
    Book foundation = new Book("Foundation");
    foundation.setPublishedYear(1951);
    foundation.addKeyWord("science fiction");
    foundation.addKeyWord("psychohistory");
    asimov.addBook(foundation);
    Book cavesofsteel = new Book("The Caves of Steel");
    cavesofsteel.setPublishedYear(1954);
    cavesofsteel.addKeyWord("science fiction");
    cavesofsteel.addKeyWord("robot");
    cavesofsteel.addKeyWord("crime");
    asimov.addBook(cavesofsteel);
    Book centerofearth = new Book("A Journey to the Center of the Earth");
    centerofearth.setPublishedYear(1864);
    centerofearth.addKeyWord("science fiction");
    centerofearth.addKeyWord("cave");
    verne.addBook(centerofearth);
    Book leagues = new Book("Twenty Thousand Leagues under the Sea");
    leagues.setPublishedYear(1869);
    leagues.addKeyWord("science fiction");
    leagues.addKeyWord("submarine");
    leagues.addKeyWord("ocean");
    verne.addBook(leagues);

    // save everything
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);
    persist.saveObject(dickens);
View Full Code Here

    this.createAuthors();
    // open a new connection
    PersistenceManager persist = new PersistenceManager(driver, database, login, password);

    // find all science fiction books
    Book seekBook = new Book();
    seekBook.addKeyWord("science fiction");
    List<Book> scifiBooks = persist.getObjects(Book.class, new Equal(seekBook));
    assertEquals(4, scifiBooks.size());
    // print the title of the scifi books
    for (Book book : scifiBooks)
    {
View Full Code Here

TOP

Related Classes of org.conserve.objects.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.