com.ten45.entity.aggregation.CrawlElementDaoBase.java Source code

Java tutorial

Introduction

Here is the source code for com.ten45.entity.aggregation.CrawlElementDaoBase.java

Source

// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by: SpringHibernateDaoBase.vsl in andromda-spring-cartridge.
//
package com.ten45.entity.aggregation;

/**
 * <p>
 * Base Spring DAO Class: is able to create, update, remove, load, and find
 * objects of type <code>com.ten45.entity.aggregation.CrawlElement</code>.
 * </p>
 *
 * @see com.ten45.entity.aggregation.CrawlElement
 */
public abstract class CrawlElementDaoBase extends com.ten45.entity.EntityDaoImpl
        implements com.ten45.entity.aggregation.CrawlElementDao {

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#load(int, java.lang.Long)
     */
    public Object load(final int transform, final java.lang.Long id) {
        if (id == null) {
            throw new IllegalArgumentException("CrawlElement.load - 'id' can not be null");
        }
        final java.util.List list = this.getHibernateTemplate()
                .find("from com.ten45.entity.aggregation.CrawlElement as entity where entity.id = ?", id);
        final Object entity = list != null && !list.isEmpty() ? list.iterator().next() : null;
        return transformEntity(transform, (com.ten45.entity.aggregation.CrawlElement) entity);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#load(int, java.lang.Long[])
     */
    public java.util.List load(final int transform, final java.lang.Long[] id) {
        if (com.ten45.basic.util.CollectionUtil.isEmpty(id)) {
            throw new IllegalArgumentException("CrawlElement.load - 'id' can not be null");
        }
        org.hibernate.Query query = getSession().createQuery(
                "from com.ten45.entity.aggregation.CrawlElement as entity where entity.id in ( :idList )");
        query.setParameterList("idList", id);
        final java.util.List<com.ten45.entity.aggregation.CrawlElement> list = query.list();
        transformEntities(transform, list);
        return list;
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#load(int, java.lang.Long[])
     */
    public java.util.List load(final int transform, final java.util.Collection<java.lang.Long> id) {
        if (com.ten45.basic.util.CollectionUtil.isEmpty(id)) {
            throw new IllegalArgumentException("CrawlElement.load - 'id' can not be null");
        }
        org.hibernate.Query query = getSession().createQuery(
                "from com.ten45.entity.aggregation.CrawlElement as entity where entity.id in ( :idList )");
        query.setParameterList("idList", id);
        final java.util.List<com.ten45.entity.aggregation.CrawlElement> list = query.list();
        transformEntities(transform, list);
        return list;
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#load(java.lang.Long)
     */
    public com.ten45.entity.aggregation.CrawlElement load(java.lang.Long id) {
        return (com.ten45.entity.aggregation.CrawlElement) this.load(TRANSFORM_NONE, id);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#load(java.lang.Long[])
     */
    public java.util.List load(java.lang.Long[] id) {
        return this.load(TRANSFORM_NONE, id);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#load(java.util.Collection<java.lang.Long>)
     */
    public java.util.List load(java.util.Collection<java.lang.Long> id) {
        return this.load(TRANSFORM_NONE, id);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#loadAll()
     */
    public java.util.Collection loadAll() {
        return this.loadAll(TRANSFORM_NONE);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#loadAll(int)
     */
    public java.util.Collection loadAll(final int transform) {
        final java.util.Collection results = this.getHibernateTemplate()
                .loadAll(com.ten45.entity.aggregation.CrawlElementImpl.class);
        this.transformEntities(transform, results);
        return results;
    }

    /**
      * @see com.ten45.entity.aggregation.CrawlElementDao#loadByCriteria(org.hibernate.criterion.DetachedCriteria)
      */
    public java.util.List loadByCriteria(org.hibernate.criterion.DetachedCriteria criteria) {
        return this.getHibernateTemplate().findByCriteria(criteria);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#create(com.ten45.entity.aggregation.CrawlElement)
     */
    public com.ten45.entity.aggregation.CrawlElement create(
            com.ten45.entity.aggregation.CrawlElement crawlElement) {
        return (com.ten45.entity.aggregation.CrawlElement) this.createEntity(crawlElement);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#create(java.net.URL, java.util.Date, java.lang.String, java.lang.Long)
     */
    public com.ten45.entity.aggregation.CrawlElement create(java.net.URL url, java.util.Date lastCrawledDate,
            java.lang.String element, java.lang.Long productID) {
        return (com.ten45.entity.aggregation.CrawlElement) this.create(TRANSFORM_NONE, url, lastCrawledDate,
                element, productID);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#create(int, java.net.URL, java.util.Date, java.lang.String, java.lang.Long)
     */
    public Object create(final int transform, java.net.URL url, java.util.Date lastCrawledDate,
            java.lang.String element, java.lang.Long productID) {
        com.ten45.entity.aggregation.CrawlElement entity = new com.ten45.entity.aggregation.CrawlElementImpl();
        entity.setUrl(url);
        entity.setLastCrawledDate(lastCrawledDate);
        entity.setElement(element);
        entity.setProductID(productID);
        return this.create(transform, entity);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#update(com.ten45.entity.aggregation.CrawlElement)
     */
    public void update(com.ten45.entity.aggregation.CrawlElement crawlElement) {
        if (crawlElement == null) {
            throw new IllegalArgumentException("CrawlElement.update - 'crawlElement' can not be null");
        }
        this.getHibernateTemplate().update(crawlElement);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#update(java.util.Collection)
     */
    public void update(final java.util.Collection entities) {
        if (entities == null) {
            throw new IllegalArgumentException("CrawlElement.update - 'entities' can not be null");
        }
        this.getHibernateTemplate().execute(new org.springframework.orm.hibernate3.HibernateCallback() {
            public Object doInHibernate(org.hibernate.Session session) throws org.hibernate.HibernateException {
                for (java.util.Iterator entityIterator = entities.iterator(); entityIterator.hasNext();) {
                    update((com.ten45.entity.aggregation.CrawlElement) entityIterator.next());
                }
                return null;
            }
        }, true);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#remove(com.ten45.entity.aggregation.CrawlElement)
     */
    public void remove(com.ten45.entity.aggregation.CrawlElement crawlElement) {
        if (crawlElement == null) {
            throw new IllegalArgumentException("CrawlElement.remove - 'crawlElement' can not be null");
        }
        this.getHibernateTemplate().delete(crawlElement);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#remove(java.lang.Long)
     */
    public void remove(java.lang.Long id) {
        if (id == null) {
            throw new IllegalArgumentException("CrawlElement.remove - 'id' can not be null");
        }
        com.ten45.entity.aggregation.CrawlElement entity = this.load(id);
        if (entity != null) {
            this.remove(entity);
        }
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElementDao#remove(java.util.Collection)
     */
    public void remove(java.util.Collection entities) {
        if (entities == null) {
            throw new IllegalArgumentException("CrawlElement.remove - 'entities' can not be null");
        }
        this.getHibernateTemplate().deleteAll(entities);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElement#loadCrawlElements(com.ten45.entity.aggregation.CrawlSession, boolean)
     */
    public java.util.Collection loadCrawlElements(com.ten45.entity.aggregation.CrawlSession crawlSession,
            boolean isCrawled) {
        return this.loadCrawlElements(TRANSFORM_NONE, crawlSession, isCrawled);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElement#loadCrawlElements(java.lang.String, com.ten45.entity.aggregation.CrawlSession, boolean)
     */
    public java.util.Collection loadCrawlElements(final java.lang.String queryString,
            final com.ten45.entity.aggregation.CrawlSession crawlSession, final boolean isCrawled) {
        return this.loadCrawlElements(TRANSFORM_NONE, queryString, crawlSession, isCrawled);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElement#loadCrawlElements(int, com.ten45.entity.aggregation.CrawlSession, boolean)
     */
    public java.util.Collection loadCrawlElements(final int transform,
            final com.ten45.entity.aggregation.CrawlSession crawlSession, final boolean isCrawled) {
        return this.loadCrawlElements(transform,
                "from com.ten45.entity.aggregation.CrawlElement as crawlElement where crawlElement.crawlSession = :crawlSession and crawlElement.isCrawled = :isCrawled",
                crawlSession, isCrawled);
    }

    /**
     * @see com.ten45.entity.aggregation.CrawlElement#loadCrawlElements(int, java.lang.String, com.ten45.entity.aggregation.CrawlSession, boolean)
     */
    public java.util.Collection loadCrawlElements(final int transform, final java.lang.String queryString,
            final com.ten45.entity.aggregation.CrawlSession crawlSession, final boolean isCrawled) {
        try {
            org.hibernate.Query queryObject = super.getSession(false).createQuery(queryString);
            queryObject.setParameter("crawlSession", crawlSession);
            queryObject.setParameter("isCrawled", new java.lang.Boolean(isCrawled));
            java.util.List results = queryObject.list();
            transformEntities(transform, results);
            return results;
        } catch (org.hibernate.HibernateException ex) {
            throw super.convertHibernateAccessException(ex);
        }
    }

}