/** * Performs an SQL query. * * @param sql the sql query */ protected void runSQL(String sql) throws SystemException { try { DataSource dataSource = bookPersistence.getDataSource(); SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource, sql, new int[0]); sqlUpdate.update(); } catch (Exception e) { throw new SystemException(e); } }
/** * Deletes the book from the database. Also notifies the appropriate model listeners. * * @param book the book * @throws SystemException if a system exception occurred */ public void deleteBook(Book book) throws SystemException { bookPersistence.remove(book); Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName()); if (indexer != null) { try { indexer.delete(book); } catch (SearchException se) { if (_log.isWarnEnabled()) { _log.warn(se, se); } } } }
/** * Updates the book in the database or adds it if it does not yet exist. Also notifies the * appropriate model listeners. * * @param book the book * @param merge whether to merge the book with the current session. See {@link * com.liferay.portal.service.persistence.BatchSession#update(com.liferay.portal.kernel.dao.orm.Session, * com.liferay.portal.model.BaseModel, boolean)} for an explanation. * @return the book that was updated * @throws SystemException if a system exception occurred */ public Book updateBook(Book book, boolean merge) throws SystemException { book.setNew(false); book = bookPersistence.update(book, merge); Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName()); if (indexer != null) { try { indexer.reindex(book); } catch (SearchException se) { if (_log.isWarnEnabled()) { _log.warn(se, se); } } } return book; }
/** * Returns the number of books. * * @return the number of books * @throws SystemException if a system exception occurred */ public int getBooksCount() throws SystemException { return bookPersistence.countAll(); }
/** * Returns a range of all the books. * * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances. * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} * will return the full result set. * * @param start the lower bound of the range of books * @param end the upper bound of the range of books (not inclusive) * @return the range of books * @throws SystemException if a system exception occurred */ public List<Book> getBooks(int start, int end) throws SystemException { return bookPersistence.findAll(start, end); }
public PersistedModel getPersistedModel(Serializable primaryKeyObj) throws PortalException, SystemException { return bookPersistence.findByPrimaryKey(primaryKeyObj); }
/** * Returns the book with the primary key. * * @param id the primary key of the book * @return the book * @throws PortalException if a book with the primary key could not be found * @throws SystemException if a system exception occurred */ public Book getBook(long id) throws PortalException, SystemException { return bookPersistence.findByPrimaryKey(id); }
public Book fetchBook(long id) throws SystemException { return bookPersistence.fetchByPrimaryKey(id); }
/** * Returns the number of rows that match the dynamic query. * * @param dynamicQuery the dynamic query * @return the number of rows that match the dynamic query * @throws SystemException if a system exception occurred */ public long dynamicQueryCount(DynamicQuery dynamicQuery) throws SystemException { return bookPersistence.countWithDynamicQuery(dynamicQuery); }
/** * Performs a dynamic query on the database and returns an ordered range of the matching rows. * * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances. * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} * will return the full result set. * * @param dynamicQuery the dynamic query * @param start the lower bound of the range of model instances * @param end the upper bound of the range of model instances (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching rows * @throws SystemException if a system exception occurred */ @SuppressWarnings("rawtypes") public List dynamicQuery( DynamicQuery dynamicQuery, int start, int end, OrderByComparator orderByComparator) throws SystemException { return bookPersistence.findWithDynamicQuery(dynamicQuery, start, end, orderByComparator); }
/** * Performs a dynamic query on the database and returns the matching rows. * * @param dynamicQuery the dynamic query * @return the matching rows * @throws SystemException if a system exception occurred */ @SuppressWarnings("rawtypes") public List dynamicQuery(DynamicQuery dynamicQuery) throws SystemException { return bookPersistence.findWithDynamicQuery(dynamicQuery); }
/** * Creates a new book with the primary key. Does not add the book to the database. * * @param id the primary key for the new book * @return the new book */ public Book createBook(long id) { return bookPersistence.create(id); }