BookService { public long modifyPrimaryBookInfo(Book book) { Arguments.mustNotBeNull( "book.id", Arguments.mustNotBeNull("book", book).getId() ); JPAEntities.validateMaxEnabledRange( book, Book_.isbn, Book_.name, Book_.price ); try (TransactionScope ts = new TransactionScope(this.connectionString)) { return ts.complete(this.bookRepository.mergeBook(book).getId()); } } BookService(String connectionString); Book getBookById(
            long id,
            /*
             * We will learn this parameter "queryPaths" in the demo project 
             * babyfishdemo-querypath, don't worry, we use it very simply in
             * this demo so that you need NOT to learn it temporarily.
             */
            Book__ ... queryPaths); long createBook(Book book); long modifyPrimaryBookInfo(Book book); long modifySecondaryBookInfo(Book book);  }
@Test public void testModifyPrimaryBookInfoFailed() { Book updateTo = new Book(); JPAEntities.disableAll(updateTo); updateTo.setId(1L); updateTo.setPublisher("China Machine Press"); try { this.bookService.modifyPrimaryBookInfo(updateTo); Assert.fail(IllegalArgumentException.class.getName() + " must be raised"); } catch (IllegalArgumentException ex) { Assert.assertTrue(ex.getMessage().contains("publisher")); } }