當前位置: 首頁>>代碼示例>>Java>>正文


Java Publisher類代碼示例

本文整理匯總了Java中com.hellokoding.jpa.model.Publisher的典型用法代碼示例。如果您正苦於以下問題:Java Publisher類的具體用法?Java Publisher怎麽用?Java Publisher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Publisher類屬於com.hellokoding.jpa.model包,在下文中一共展示了Publisher類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import com.hellokoding.jpa.model.Publisher; //導入依賴的package包/類
@Override
@Transactional
public void run(String... strings) throws Exception {
    Book bookA = new Book("Book A");

    Publisher publisherA = new Publisher("Publisher A");

    BookPublisher bookPublisher = new BookPublisher();
    bookPublisher.setBook(bookA);
    bookPublisher.setPublisher(publisherA);
    bookPublisher.setPublishedDate(new Date());
    bookA.getBookPublishers().add(bookPublisher);

    publisherRepository.save(publisherA);
    bookRepository.save(bookA);

    // test
    System.out.println(bookA.getBookPublishers().size());

    // update
    bookA.getBookPublishers().remove(bookPublisher);
    bookRepository.save(bookA);

    // test
    System.out.println(bookA.getBookPublishers().size());
}
 
開發者ID:hellokoding,項目名稱:jpa-manytomany-extracolumns-springboot-maven-mysql,代碼行數:27,代碼來源:HelloJpaApplication.java

示例2: run

import com.hellokoding.jpa.model.Publisher; //導入依賴的package包/類
@Override
@Transactional
public void run(String... strings) throws Exception {
    // save a couple of books
    final Publisher publisherA = new Publisher("Publisher A");
    final Publisher publisherB = new Publisher("Publisher B");
    final Publisher publisherC = new Publisher("Publisher C");

    bookRepository.save(new HashSet<Book>(){{
        add(new Book("Book A", new HashSet<Publisher>(){{
            add(publisherA);
            add(publisherB);
        }}));

        add(new Book("Book B", new HashSet<Publisher>(){{
            add(publisherA);
            add(publisherC);
        }}));
    }});

    // fetch all books
    for(Book book : bookRepository.findAll()) {
        logger.info(book.toString());
    }

    // save a couple of publishers
    final Book bookA = new Book("Book A");
    final Book bookB = new Book("Book B");

    publisherRepository.save(new HashSet<Publisher>() {{
        add(new Publisher("Publisher A", new HashSet<Book>() {{
            add(bookA);
            add(bookB);
        }}));

        add(new Publisher("Publisher B", new HashSet<Book>() {{
            add(bookA);
            add(bookB);
        }}));
    }});

    // fetch all publishers
    for(Publisher publisher : publisherRepository.findAll()) {
        logger.info(publisher.toString());
    }
}
 
開發者ID:hellokoding,項目名稱:jpa-manytomany-springboot-hsql,代碼行數:47,代碼來源:HelloJpaApplication.java

示例3: run

import com.hellokoding.jpa.model.Publisher; //導入依賴的package包/類
@Override
@Transactional
public void run(String... strings) throws Exception {
    // save a couple of books
    Publisher publisherA = new Publisher("Publisher A");
    Publisher publisherB = new Publisher("Publisher B");
    Publisher publisherC = new Publisher("Publisher C");

    bookRepository.save(new HashSet<Book>(){{
        add(new Book("Book A", new HashSet<Publisher>(){{
            add(publisherA);
            add(publisherB);
        }}));

        add(new Book("Book B", new HashSet<Publisher>(){{
            add(publisherA);
            add(publisherC);
        }}));
    }});

    // fetch all books
    for(Book book : bookRepository.findAll()) {
        logger.info(book.toString());
    }

    // save a couple of publishers
    Book bookA = new Book("Book A");
    Book bookB = new Book("Book B");

    publisherRepository.save(new HashSet<Publisher>() {{
        add(new Publisher("Publisher A", new HashSet<Book>() {{
            add(bookA);
            add(bookB);
        }}));

        add(new Publisher("Publisher B", new HashSet<Book>() {{
            add(bookA);
            add(bookB);
        }}));
    }});

    // fetch all publishers
    for(Publisher publisher : publisherRepository.findAll()) {
        logger.info(publisher.toString());
    }
}
 
開發者ID:hellokoding,項目名稱:jpa-manytomany-springboot-maven-mysql,代碼行數:47,代碼來源:HelloJpaApplication.java


注:本文中的com.hellokoding.jpa.model.Publisher類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。