Example usage for org.hibernate FetchMode SELECT

List of usage examples for org.hibernate FetchMode SELECT

Introduction

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

Prototype

FetchMode SELECT

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

Click Source Link

Document

Fetch eagerly, using a separate select.

Usage

From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.Domain.java

License:Open Source License

@Transient
@SuppressWarnings("unchecked")
public final Set<Reservation> getAllReservations() throws DatabaseException {
    return (Set<Reservation>) (new TransactionManager(this) {
        @Override//  w  w w.ja  va 2 s .  c om
        protected void dbOperation() throws Exception {
            final Domain me = (Domain) this.arg;

            final List<NrpsConnections> cList = this.session.createCriteria(NrpsConnections.class)
                    .setFetchMode("", FetchMode.SELECT).add(Restrictions.like("domain", me)).list();

            final Set<Connections> connections = new HashSet<Connections>();
            for (final NrpsConnections nConn : cList) {
                connections.add(nConn.getConnection());
            }

            // get services for every connection
            final Set<Service> services = new HashSet<Service>();
            for (final Connections c : connections) {
                services.add(c.getService());
            }
            // get reservations for every Service
            final Set<Reservation> reservations = new HashSet<Reservation>();
            for (final Service s : services) {
                reservations.add(s.getReservation());
            }

            this.result = reservations;
        }
    }).getResult();
}

From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.DomSupportedAdaption.java

License:Open Source License

@SuppressWarnings("unchecked")
public static Set<DomSupportedAdaption> loadAll(Domain dom) throws DatabaseException {
    return (Set<DomSupportedAdaption>) (new TransactionManager(dom) {
        @Override//  w w  w .j  av  a 2  s. c  om
        protected void dbOperation() {
            final Domain d = (Domain) this.arg;

            final List<DomSupportedAdaption> aList = this.session.createCriteria(DomSupportedAdaption.class)
                    .setFetchMode("", FetchMode.SELECT).add(Restrictions.like("domain", d)).list();

            final Set<DomSupportedAdaption> adaptions = new HashSet<DomSupportedAdaption>();
            for (final DomSupportedAdaption adaption : aList) {
                adaptions.add(adaption);
            }
            this.result = adaptions;
        }
    }).getResult();
}

From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.DomSupportedBandwidth.java

License:Open Source License

@SuppressWarnings("unchecked")
public static Set<DomSupportedBandwidth> loadAll(Domain dom) throws DatabaseException {
    return (Set<DomSupportedBandwidth>) (new TransactionManager(dom) {
        @Override/*from  www .ja v  a 2  s . co  m*/
        protected void dbOperation() {
            final Domain d = (Domain) this.arg;

            final List<DomSupportedBandwidth> bList = this.session.createCriteria(DomSupportedBandwidth.class)
                    .setFetchMode("", FetchMode.SELECT).add(Restrictions.like("domain", d)).list();

            final Set<DomSupportedBandwidth> bws = new HashSet<DomSupportedBandwidth>();
            for (final DomSupportedBandwidth bw : bList) {
                bws.add(bw);
            }
            this.result = bws;
        }
    }).getResult();
}

From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.DomSupportedSwitch.java

License:Open Source License

@SuppressWarnings("unchecked")
public static Set<DomSupportedSwitch> loadAll(Domain dom) throws DatabaseException {
    return (Set<DomSupportedSwitch>) (new TransactionManager(dom) {
        @Override/* w  ww.ja va  2s. c  o m*/
        protected void dbOperation() {
            final Domain d = (Domain) this.arg;

            final List<DomSupportedSwitch> sList = this.session.createCriteria(DomSupportedSwitch.class)
                    .setFetchMode("", FetchMode.SELECT).add(Restrictions.like("domain", d)).list();

            final Set<DomSupportedSwitch> switches = new HashSet<DomSupportedSwitch>();
            for (final DomSupportedSwitch switchd : sList) {
                switches.add(switchd);
            }
            this.result = switches;
        }
    }).getResult();
}

From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.Endpoint.java

License:Open Source License

@SuppressWarnings("unchecked")
public static final Set<Endpoint> loadAll() throws DatabaseException {
    return (Set<Endpoint>) (new TransactionManager() {
        @Override//  w w w  .ja  v a  2 s.  c  om
        protected void dbOperation() {
            Set<Endpoint> result = new HashSet<Endpoint>();
            final List<Endpoint> tmpEndpoint = this.session.createCriteria(Endpoint.class)
                    .setFetchMode("Endpoint", FetchMode.SELECT).list();
            for (Endpoint d : tmpEndpoint) {
                result.add(d);
            }
            this.result = result;
        }
    }).getResult();
}

From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.Endpoint.java

License:Open Source License

@SuppressWarnings("unchecked")
public final Set<VIEW_InterDomainLink> loadLinks() throws DatabaseException {
    return (Set<VIEW_InterDomainLink>) (new TransactionManager(this) {
        @Override/*from w  w w  . j  av  a 2 s. c  o  m*/
        protected void dbOperation() {
            final Set<VIEW_InterDomainLink> result = new HashSet<VIEW_InterDomainLink>();
            final List<VIEW_InterDomainLink> tmpSrc = this.session.createCriteria(VIEW_InterDomainLink.class)
                    .setFetchMode("", FetchMode.SELECT).add(Restrictions.like("sourceEndpoint", this.arg))
                    .list();
            final List<VIEW_InterDomainLink> tmpDst = this.session.createCriteria(VIEW_InterDomainLink.class)
                    .setFetchMode("", FetchMode.SELECT).add(Restrictions.like("destEndpoint", this.arg)).list();
            for (final VIEW_InterDomainLink l : tmpSrc) {
                result.add(l);
            }
            for (final VIEW_InterDomainLink l : tmpDst) {
                result.add(l);
            }
            this.result = result;
        }
    }).getResult();
}

From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.InterDomainLink.java

License:Open Source License

/**
 * Load all InterDomainLinks/*from w  w  w .  j a va  2s. c o m*/
 * 
 * @return
 * @throws DatabaseException
 */
@SuppressWarnings("unchecked")
public static final Set<InterDomainLink> loadAll() throws DatabaseException {
    return (Set<InterDomainLink>) (new TransactionManager() {
        @Override
        protected void dbOperation() {
            Set<InterDomainLink> result = new HashSet<InterDomainLink>();
            final List<InterDomainLink> tmpLink = this.session.createCriteria(InterDomainLink.class)
                    .setFetchMode("InterDomainLink", FetchMode.SELECT).list();
            for (InterDomainLink l : tmpLink) {
                result.add(l);
            }
            this.result = result;
        }
    }).getResult();
}

From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.MAPNRPSResvID.java

License:Open Source License

@Transient
@SuppressWarnings("unchecked")
public static final List<MAPNRPSResvID> getMappingForReservation(final Reservation res)
        throws DatabaseException {
    final Session session = DbConnectionManager.openSession();
    final List<MAPNRPSResvID> tmpMAPResConnDom = session.createCriteria(MAPNRPSResvID.class)
            .setFetchMode("", FetchMode.SELECT).add(Restrictions.like("reservation", res)).list();
    session.close();//ww w.jav a 2  s .  co  m
    return tmpMAPResConnDom;
}

From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.Reservation.java

License:Open Source License

/**
 * load all existing reservations from DB
 * //ww  w  .  jav a  2s .c  o  m
 * @return
 * @throws DatabaseException
 */
@SuppressWarnings("unchecked")
public static final Set<Reservation> loadAll() throws DatabaseException {
    return (Set<Reservation>) (new TransactionManager() {
        @Override
        protected void dbOperation() {
            Set<Reservation> result = new HashSet<Reservation>();
            final List<Reservation> tmpReservation = this.session.createCriteria(Reservation.class)
                    .setFetchMode("Reservation", FetchMode.SELECT).list();
            for (Reservation r : tmpReservation) {
                result.add(r);
            }
            this.result = result;
        }
    }).getResult();
}

From source file:eu.ist_phosphorus.harmony.idb.database.hibernate.Reservation.java

License:Open Source License

/**
 * Get reservations summarized under one job-Id.
 * //w ww  .j  av a  2  s .  c o  m
 * @param jobId
 *            Id which summarizes reservations
 * @return List of Reservations summarized under the committed job-Id
 * @throws DatabaseException
 */
@SuppressWarnings("unchecked")
public static final List<Reservation> loadJob(final long jobId) throws DatabaseException {
    return (List<Reservation>) (new TransactionManager("jobID=" + jobId) {
        @Override
        protected void dbOperation() {
            this.result = this.session.createCriteria(Reservation.class).setFetchMode("", FetchMode.SELECT)
                    .add(Expression.sql((String) this.arg)).list();
        }
    }).getResult();
}