/** * Performs an SQL query. * * @param sql the sql query */ protected void runSQL(String sql) throws SystemException { try { DataSource dataSource = linkPersistence.getDataSource(); SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource, sql, new int[0]); sqlUpdate.update(); } catch (Exception e) { throw new SystemException(e); } }
/** * Updates the link in the database or adds it if it does not yet exist. Also notifies the * appropriate model listeners. * * @param link the link * @param merge whether to merge the link 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 link that was updated * @throws SystemException if a system exception occurred */ @Indexable(type = IndexableType.REINDEX) public Link updateLink(Link link, boolean merge) throws SystemException { link.setNew(false); return linkPersistence.update(link, merge); }
/** * Returns the number of links. * * @return the number of links * @throws SystemException if a system exception occurred */ public int getLinksCount() throws SystemException { return linkPersistence.countAll(); }
/** * Returns a range of all the links. * * <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 links * @param end the upper bound of the range of links (not inclusive) * @return the range of links * @throws SystemException if a system exception occurred */ public List<Link> getLinks(int start, int end) throws SystemException { return linkPersistence.findAll(start, end); }
public PersistedModel getPersistedModel(Serializable primaryKeyObj) throws PortalException, SystemException { return linkPersistence.findByPrimaryKey(primaryKeyObj); }
/** * Returns the link with the primary key. * * @param linkId the primary key of the link * @return the link * @throws PortalException if a link with the primary key could not be found * @throws SystemException if a system exception occurred */ public Link getLink(long linkId) throws PortalException, SystemException { return linkPersistence.findByPrimaryKey(linkId); }
public Link fetchLink(long linkId) throws SystemException { return linkPersistence.fetchByPrimaryKey(linkId); }
/** * 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 linkPersistence.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 linkPersistence.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 linkPersistence.findWithDynamicQuery(dynamicQuery); }
/** * Deletes the link from the database. Also notifies the appropriate model listeners. * * @param link the link * @return the link that was removed * @throws SystemException if a system exception occurred */ @Indexable(type = IndexableType.DELETE) public Link deleteLink(Link link) throws SystemException { return linkPersistence.remove(link); }
/** * Deletes the link with the primary key from the database. Also notifies the appropriate model * listeners. * * @param linkId the primary key of the link * @return the link that was removed * @throws PortalException if a link with the primary key could not be found * @throws SystemException if a system exception occurred */ @Indexable(type = IndexableType.DELETE) public Link deleteLink(long linkId) throws PortalException, SystemException { return linkPersistence.remove(linkId); }
/** * Creates a new link with the primary key. Does not add the link to the database. * * @param linkId the primary key for the new link * @return the new link */ public Link createLink(long linkId) { return linkPersistence.create(linkId); }
/** * Adds the link to the database. Also notifies the appropriate model listeners. * * @param link the link * @return the link that was added * @throws SystemException if a system exception occurred */ @Indexable(type = IndexableType.REINDEX) public Link addLink(Link link) throws SystemException { link.setNew(true); return linkPersistence.update(link, false); }