Example usage for javax.persistence FetchType LAZY

List of usage examples for javax.persistence FetchType LAZY

Introduction

In this page you can find the example usage for javax.persistence FetchType LAZY.

Prototype

FetchType LAZY

To view the source code for javax.persistence FetchType LAZY.

Click Source Link

Document

Defines that data can be lazily fetched.

Usage

From source file:py.una.pol.karaku.dao.util.MainInstanceHelper.java

/**
 * /*w  ww  .  jav  a2 s .c  o  m*/
 * @param criteria
 * @param fields
 *            lista de fields que tienen la anotacin {@link MainInstance},
 *            solo atiende a los fields que son eager
 * @return mapa de alias
 */

private Map<String, String> configureCriteria(final Criteria criteria, final List<Field> fields,
        final Map<String, String> alias) {

    for (Field f : fields) {

        MainInstance mi = f.getAnnotation(MainInstance.class);
        if (mi.fetch().equals(FetchType.LAZY)) {
            continue;
        }
        String newAlias = alias.get(mi.attribute());
        if (newAlias == null) {
            newAlias = generateAlias(mi);

            criteria.createCriteria(mi.attribute(), newAlias, JoinType.LEFT_OUTER_JOIN).add(
                    Restrictions.or(Restrictions.like(mi.path(), mi.value()), Restrictions.isNull(mi.path())));
            alias.put(f.getName(), newAlias);
        } else {
            criteria.add(Restrictions.or(Restrictions.like(newAlias + "." + mi.path(), mi.value()),
                    Restrictions.isNull(newAlias + "." + mi.path())));
        }

    }
    criteria.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    return alias;
}

From source file:gov.nih.nci.cabig.caaers.domain.Organization.java

/**
 * Gets the study organizations./*from w w  w  .  j ava 2  s.c  om*/
 *
 * @return the study organizations
 */
@OneToMany(mappedBy = "organization", fetch = FetchType.LAZY, orphanRemoval = true)
@OrderBy
// order by ID for testing consistency
@Cascade(value = { CascadeType.DELETE })
@Fetch(value = org.hibernate.annotations.FetchMode.SUBSELECT)
public List<StudyOrganization> getStudyOrganizations() {
    return studyOrganizations;
}

From source file:com.doculibre.constellio.entities.Record.java

@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, orphanRemoval = true)
@JoinTable(name = "Record_ContentMetas", joinColumns = {
        @JoinColumn(name = "record_id") }, inverseJoinColumns = { @JoinColumn(name = "meta_id") })
@OrderColumn/*from   w w  w  .  j a  v  a  2  s.  co  m*/
public List<RecordMeta> getContentMetas() {
    return contentMetas;
}

From source file:org.opennms.rest.client.model.OnmsIpInterface.java

/**
 * <p>getNode</p>//from  ww  w.  ja  v a2  s.co  m
 *
 * @return a {@link org.opennms.netmgt.model.OnmsNode} object.
 */
@ManyToOne(optional = false, fetch = FetchType.LAZY)
@JoinColumn(name = "nodeId")
@XmlElement(name = "nodeId")
//@XmlIDREF
@XmlJavaTypeAdapter(NodeIdAdapter.class)
public OnmsNode getNode() {
    return m_node;
}

From source file:com.dp2345.entity.Coupon.java

/**
 * ?
 * 
 * @return 
 */
@ManyToMany(mappedBy = "coupons", fetch = FetchType.LAZY)
public Set<Promotion> getPromotions() {
    return promotions;
}

From source file:ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE.java

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = ColumnNames.CONTROL_LAYOUT_SAMPLE_COLUMN, updatable = false)
public SamplePE getControlLayout() {
    return controlLayout;
}

From source file:com.esoft.jdp2p.borrower.model.BorrowerAuthentication.java

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "car_info")
public AuthenticationMaterials getCarInfo() {
    return this.carInfo;
}

From source file:org.dspace.orm.entity.EpersonGroup.java

@OneToMany(fetch = FetchType.LAZY, mappedBy = "workflowStep1")
public List<Collection> getWorkflowstep1Collections() {
    return workflowstep1Collections;
}

From source file:com.marand.thinkmed.medications.model.impl.MedicationImpl.java

@Override
@OneToMany(targetEntity = MedicationFormularyImpl.class, mappedBy = "medication", fetch = FetchType.LAZY)
public Set<MedicationFormulary> getFormulary() {
    return formulary;
}

From source file:edu.duke.cabig.c3pr.domain.StudyVersion.java

@OneToMany(fetch = FetchType.LAZY, orphanRemoval = true)
@JoinColumn(name = "stu_version_id")
@Cascade(value = { CascadeType.ALL })//from w w w  .j  a  v a2  s .  c  om
@Where(clause = "retired_indicator  = 'false'")
@OrderBy("epochOrder")
public List<Epoch> getEpochsInternal() {
    return lazyListHelper.getInternalList(Epoch.class);
}