javax.persistence.criteria.Fetch.fetch()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中javax.persistence.criteria.Fetch.fetch()方法的一些代码示例,展示了Fetch.fetch()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fetch.fetch()方法的具体详情如下:
包路径:javax.persistence.criteria.Fetch
类名称:Fetch
方法名:fetch

Fetch.fetch介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void test_criteria_from_fetch_example() {
  doInJPA( this::entityManagerFactory, entityManager -> {
    //tag::criteria-from-fetch-example[]
    CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    CriteriaQuery<Phone> criteria = builder.createQuery( Phone.class );
    Root<Phone> root = criteria.from( Phone.class );
    // Phone.person is a @ManyToOne
    Fetch<Phone, Person> personFetch = root.fetch( Phone_.person );
    // Person.addresses is an @ElementCollection
    Fetch<Person, String> addressesJoin = personFetch.fetch( Person_.addresses );
    criteria.where( builder.isNotEmpty( root.get( Phone_.calls ) ) );
    List<Phone> phones = entityManager.createQuery( criteria ).getResultList();
    //end::criteria-from-fetch-example[]
    assertEquals(2, phones.size());
  });
}

代码示例来源:origin: org.omnifaces/omnipersistence

@Override
public <Y> Fetch<X, Y> fetch(PluralAttribute<? super X, ?, Y> attribute, JoinType jt) {
  return getWrapped().fetch(attribute, jt);
}

代码示例来源:origin: org.omnifaces/omnipersistence

@Override
@SuppressWarnings("hiding")
public <X, Y> Fetch<X, Y> fetch(String attributeName) {
  return getWrapped().fetch(attributeName);
}

代码示例来源:origin: org.jasig.portal/uPortal-web

/** Add all the fetches needed for completely loading the object graph */
protected void addFetches(final Root<PortletEntityImpl> definitionRoot) {
  definitionRoot
      .fetch(PortletEntityImpl_.portletPreferences, JoinType.LEFT)
      .fetch(PortletPreferencesImpl_.portletPreferences, JoinType.LEFT)
      .fetch(PortletPreferenceImpl_.values, JoinType.LEFT);
  definitionRoot.fetch(PortletEntityImpl_.windowStates, JoinType.LEFT);
}

代码示例来源:origin: org.omnifaces/omnipersistence

@Override
public <Y> Fetch<X, Y> fetch(SingularAttribute<? super X, Y> attribute, JoinType jt) {
  return getWrapped().fetch(attribute, jt);
}

代码示例来源:origin: org.omnifaces/omnipersistence

@Override
@SuppressWarnings("hiding")
public <X, Y> Fetch<X, Y> fetch(String attributeName, JoinType jt) {
  return getWrapped().fetch(attributeName, jt);
}

代码示例来源:origin: org.omnifaces/omnipersistence

@Override
public <Y> Fetch<X, Y> fetch(SingularAttribute<? super X, Y> attribute) {
  return getWrapped().fetch(attribute);
}

代码示例来源:origin: org.omnifaces/omnipersistence

@Override
public <Y> Fetch<X, Y> fetch(PluralAttribute<? super X, ?, Y> attribute) {
  return getWrapped().fetch(attribute);
}

代码示例来源:origin: org.jasig.portal/uPortal-persondir

@Override
  public CriteriaQuery<LocalAccountPersonImpl> apply(CriteriaBuilder cb) {
    final CriteriaQuery<LocalAccountPersonImpl> criteriaQuery =
        cb.createQuery(LocalAccountPersonImpl.class);
    final Root<LocalAccountPersonImpl> accountRoot =
        criteriaQuery.from(LocalAccountPersonImpl.class);
    accountRoot
        .fetch(LocalAccountPersonImpl_.attributes, JoinType.LEFT)
        .fetch(
            LocalAccountPersonAttributeImpl_.values,
            JoinType.LEFT);
    criteriaQuery.select(accountRoot);
    return criteriaQuery;
  }
});

代码示例来源:origin: Jasig/uPortal

@Override
  public CriteriaQuery<LocalAccountPersonImpl> apply(CriteriaBuilder cb) {
    final CriteriaQuery<LocalAccountPersonImpl> criteriaQuery =
        cb.createQuery(LocalAccountPersonImpl.class);
    final Root<LocalAccountPersonImpl> accountRoot =
        criteriaQuery.from(LocalAccountPersonImpl.class);
    accountRoot
        .fetch(LocalAccountPersonImpl_.attributes, JoinType.LEFT)
        .fetch(
            LocalAccountPersonAttributeImpl_.values,
            JoinType.LEFT);
    criteriaQuery.select(accountRoot);
    return criteriaQuery;
  }
});

代码示例来源:origin: Jasig/uPortal

@Override
  public CriteriaQuery<LocalAccountPersonImpl> apply(CriteriaBuilder cb) {
    final CriteriaQuery<LocalAccountPersonImpl> criteriaQuery =
        cb.createQuery(LocalAccountPersonImpl.class);
    final Root<LocalAccountPersonImpl> accountRoot =
        criteriaQuery.from(LocalAccountPersonImpl.class);
    accountRoot
        .fetch(LocalAccountPersonImpl_.attributes, JoinType.LEFT)
        .fetch(
            LocalAccountPersonAttributeImpl_.values,
            JoinType.LEFT);
    criteriaQuery.select(accountRoot);
    criteriaQuery.where(
        cb.equal(
            accountRoot.get(LocalAccountPersonImpl_.name),
            nameParameter));
    return criteriaQuery;
  }
});

代码示例来源:origin: org.jasig.portal/uPortal-persondir

@Override
  public CriteriaQuery<LocalAccountPersonImpl> apply(CriteriaBuilder cb) {
    final CriteriaQuery<LocalAccountPersonImpl> criteriaQuery =
        cb.createQuery(LocalAccountPersonImpl.class);
    final Root<LocalAccountPersonImpl> accountRoot =
        criteriaQuery.from(LocalAccountPersonImpl.class);
    accountRoot
        .fetch(LocalAccountPersonImpl_.attributes, JoinType.LEFT)
        .fetch(
            LocalAccountPersonAttributeImpl_.values,
            JoinType.LEFT);
    criteriaQuery.select(accountRoot);
    criteriaQuery.where(
        cb.equal(
            accountRoot.get(LocalAccountPersonImpl_.name),
            nameParameter));
    return criteriaQuery;
  }
});

代码示例来源:origin: adamzareba/company-structure-spring-security-oauth2-authorities

@Override
public Company find(String name) {
  CriteriaBuilder builder = entityManager.getCriteriaBuilder();
  CriteriaQuery<Company> query = builder.createQuery(Company.class);
  Root<Company> root = query.from(Company.class);
  root.fetch(Company_.cars, JoinType.LEFT);
  Fetch<Company, Department> departmentFetch = root.fetch(Company_.departments, JoinType.LEFT);
  Fetch<Department, Employee> employeeFetch = departmentFetch.fetch(Department_.employees, JoinType.LEFT);
  employeeFetch.fetch(Employee_.address, JoinType.LEFT);
  departmentFetch.fetch(Department_.offices, JoinType.LEFT);
  query.select(root).distinct(true);
  Predicate idPredicate = builder.equal(root.get(Company_.name), name);
  query.where(builder.and(idPredicate));
  return DataAccessUtils.singleResult(entityManager.createQuery(query).getResultList());
}

代码示例来源:origin: adamzareba/company-structure-spring-security-oauth2-authorities

@Override
public Company find(Long id) {
  CriteriaBuilder builder = entityManager.getCriteriaBuilder();
  CriteriaQuery<Company> query = builder.createQuery(Company.class);
  Root<Company> root = query.from(Company.class);
  root.fetch(Company_.cars, JoinType.LEFT);
  Fetch<Company, Department> departmentFetch = root.fetch(Company_.departments, JoinType.LEFT);
  Fetch<Department, Employee> employeeFetch = departmentFetch.fetch(Department_.employees, JoinType.LEFT);
  employeeFetch.fetch(Employee_.address, JoinType.LEFT);
  departmentFetch.fetch(Department_.offices, JoinType.LEFT);
  query.select(root).distinct(true);
  Predicate idPredicate = builder.equal(root.get(Company_.id), id);
  query.where(builder.and(idPredicate));
  return DataAccessUtils.singleResult(entityManager.createQuery(query).getResultList());
}

代码示例来源:origin: uaihebert/uaicriteria

public JoinWrapper createJoinFromJoin(final String joinName, final JoinType joinType) {
  if (join != null) {
    final Join innerJoin = join.join(joinName, joinType);
    return new JoinWrapper(innerJoin);
  }
  final Fetch innerJoin = joinFetch.fetch(joinName, joinType);
  return new JoinWrapper(innerJoin);
}

代码示例来源:origin: org.jboss.pressgang.ccms/pressgang-ccms-query

/**
   * Copy Fetches
   *
   * @param from source Fetch
   * @param to   dest Fetch
   */
  public static void copyFetches(Fetch<?, ?> from, Fetch<?, ?> to) {
    for (Fetch<?, ?> f : from.getFetches()) {
      Fetch<?, ?> toFetch = to.fetch(f.getAttribute().getName());
      // recursively copy fetches
      copyFetches(f, toFetch);
    }
  }
}

代码示例来源:origin: org.lorislab.armonitor/armonitor-ejb

Fetch<StoreActivityChange, StoreActivityLog> lf = chf.fetch(StoreActivityChange_.logs, JoinType.LEFT);
  lf.fetch(StoreActivityLog_.build, JoinType.LEFT);

代码示例来源:origin: org.lorislab.armonitor/armonitor-ejb

bf.fetch(StoreBuild_.parameters, JoinType.LEFT);
bf.fetch(StoreSystem_.application, JoinType.LEFT);

代码示例来源:origin: org.lorislab.armonitor/armonitor-ejb

pf.fetch(StoreApplication_.project, JoinType.LEFT);

代码示例来源:origin: org.lorislab.armonitor/armonitor-ejb

pf.fetch(StoreProject_.bts, JoinType.LEFT);

相关文章