Example usage for org.hibernate FetchMode EAGER

List of usage examples for org.hibernate FetchMode EAGER

Introduction

In this page you can find the example usage for org.hibernate FetchMode EAGER.

Prototype

FetchMode EAGER

To view the source code for org.hibernate FetchMode EAGER.

Click Source Link

Document

Fetch eagerly, using an outer join.

Usage

From source file:org.sakaiproject.component.app.syllabus.SyllabusManagerImpl.java

License:Educational Community License

@SuppressWarnings("unchecked")
public Set<SyllabusData> findPublicSyllabusData() {
    HibernateCallback hcb = new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            Criteria crit = session.createCriteria(SyllabusDataImpl.class).add(Expression.eq(VIEW, "yes"))
                    .setFetchMode(ATTACHMENTS, FetchMode.EAGER);

            return crit.list();
        }//from   ww w.j a  v a2 s  .c o m
    };
    return new HashSet<SyllabusData>((List<SyllabusData>) getHibernateTemplate().executeFind(hcb));
}

From source file:org.sakaiproject.component.app.syllabus.SyllabusManagerImpl.java

License:Educational Community License

public Set getSyllabusAttachmentsForSyllabusData(final SyllabusData syllabusData) {
    if (syllabusData == null) {
        throw new IllegalArgumentException("Null Argument");
    } else {//from  ww  w  .jav  a  2 s  .co  m
        HibernateCallback hcb = new HibernateCallback() {
            public Object doInHibernate(Session session) throws HibernateException, SQLException {
                Criteria crit = session.createCriteria(SyllabusDataImpl.class)
                        .add(Expression.eq(SYLLABUS_DATA_ID, syllabusData.getSyllabusId()))
                        .setFetchMode(ATTACHMENTS, FetchMode.EAGER);

                SyllabusData syllabusData = (SyllabusData) crit.uniqueResult();

                if (syllabusData != null) {
                    return syllabusData.getAttachments();
                }
                return new TreeSet();
            }
        };
        return (Set<SyllabusAttachment>) getHibernateTemplate().execute(hcb);
    }
}