org.apache.openjpa.persistence.QueryImpl.popQueryFetchPlan()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(78)

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

QueryImpl.popQueryFetchPlan介绍

暂无

代码示例

代码示例来源:origin: org.apache.openejb.patch/openjpa

public List getResultList() {
  _em.assertNotCloseInvoked();
  boolean queryFetchPlanUsed = pushQueryFetchPlan();
  try {
    Object ob = execute();
    if (ob instanceof List) {
      List ret = (List) ob;
      if (ret instanceof ResultList) {
        RuntimeExceptionTranslator trans = PersistenceExceptions.getRollbackTranslator(_em);
        if (_query.isDistinct()) {
          return new DistinctResultList((ResultList) ret, trans);
        } else {
          return new DelegatingResultList((ResultList) ret, trans);
        }
      } else {
        return ret;
      }
    }
    return Collections.singletonList(ob);
  } finally {
    popQueryFetchPlan(queryFetchPlanUsed);
  }
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

public List getResultList() {
  _em.assertNotCloseInvoked();
  boolean queryFetchPlanUsed = pushQueryFetchPlan();
  try {
    Object ob = execute();
    if (ob instanceof List) {
      List ret = (List) ob;
      if (ret instanceof ResultList) {
        RuntimeExceptionTranslator trans = PersistenceExceptions.getRollbackTranslator(_em);
        if (_query.isDistinct()) {
          return new DistinctResultList((ResultList) ret, trans);
        } else {
          return new DelegatingResultList((ResultList) ret, trans);
        }
      } else {
        return ret;
      }
    }
    return Collections.singletonList(ob);
  } finally {
    popQueryFetchPlan(queryFetchPlanUsed);
  }
}

代码示例来源:origin: org.apache.openjpa/openjpa-persistence

public List getResultList() {
  _em.assertNotCloseInvoked();
  boolean queryFetchPlanUsed = pushQueryFetchPlan();
  try {
    Object ob = execute();
    if (ob instanceof List) {
      List ret = (List) ob;
      if (ret instanceof ResultList) {
        RuntimeExceptionTranslator trans = PersistenceExceptions.getRollbackTranslator(_em);
        if (_query.isDistinct()) {
          return new DistinctResultList((ResultList) ret, trans);
        } else {
          return new DelegatingResultList((ResultList) ret, trans);
        }
      } else {
        return ret;
      }
    }
    return Collections.singletonList(ob);
  } finally {
    popQueryFetchPlan(queryFetchPlanUsed);
  }
}

代码示例来源:origin: org.apache.openejb.patch/openjpa-persistence

public List getResultList() {
  _em.assertNotCloseInvoked();
  boolean queryFetchPlanUsed = pushQueryFetchPlan();
  try {
    Object ob = execute();
    if (ob instanceof List) {
      List ret = (List) ob;
      if (ret instanceof ResultList) {
        RuntimeExceptionTranslator trans = PersistenceExceptions.getRollbackTranslator(_em);
        if (_query.isDistinct()) {
          return new DistinctResultList((ResultList) ret, trans);
        } else {
          return new DelegatingResultList((ResultList) ret, trans);
        }
      } else {
        return ret;
      }
    }
    return Collections.singletonList(ob);
  } finally {
    popQueryFetchPlan(queryFetchPlanUsed);
  }
}

代码示例来源:origin: org.apache.openjpa/openjpa-persistence

/**
 * Execute a query that returns a single result.
 */
public X getSingleResult() {
  _em.assertNotCloseInvoked();
  setHint(QueryHints.HINT_RESULT_COUNT, 1); // for DB2 optimization
  boolean queryFetchPlanUsed = pushQueryFetchPlan();
  try {
    List result = getResultList();
    if (result == null || result.isEmpty())
      throw new NoResultException(_loc.get("no-result", getQueryString())
          .getMessage());
    if (result.size() > 1)
      throw new NonUniqueResultException(_loc.get("non-unique-result",
          getQueryString(), result.size()).getMessage());
    try {
      return (X)result.get(0);
    } catch (Exception e) {
      throw new NoResultException(_loc.get("no-result", getQueryString())
        .getMessage());
    }
  } finally {
    popQueryFetchPlan(queryFetchPlanUsed);
  }
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Execute a query that returns a single result.
 */
public X getSingleResult() {
  _em.assertNotCloseInvoked();
  setHint(QueryHints.HINT_RESULT_COUNT, 1); // for DB2 optimization
  boolean queryFetchPlanUsed = pushQueryFetchPlan();
  try {
    List result = getResultList();
    if (result == null || result.isEmpty())
      throw new NoResultException(_loc.get("no-result", getQueryString())
          .getMessage());
    if (result.size() > 1)
      throw new NonUniqueResultException(_loc.get("non-unique-result",
          getQueryString(), result.size()).getMessage());
    try {
      return (X)result.get(0);
    } catch (Exception e) {
      throw new NoResultException(_loc.get("no-result", getQueryString())
        .getMessage());
    }
  } finally {
    popQueryFetchPlan(queryFetchPlanUsed);
  }
}

代码示例来源:origin: org.apache.openejb.patch/openjpa-persistence

/**
 * Execute a query that returns a single result.
 */
public X getSingleResult() {
  _em.assertNotCloseInvoked();
  setHint(QueryHints.HINT_RESULT_COUNT, 1); // for DB2 optimization
  boolean queryFetchPlanUsed = pushQueryFetchPlan();
  try {
    List result = getResultList();
    if (result == null || result.isEmpty())
      throw new NoResultException(_loc.get("no-result", getQueryString())
          .getMessage());
    if (result.size() > 1)
      throw new NonUniqueResultException(_loc.get("non-unique-result",
          getQueryString(), result.size()).getMessage());
    try {
      return (X)result.get(0);
    } catch (Exception e) {
      throw new NoResultException(_loc.get("no-result", getQueryString())
        .getMessage());
    }
  } finally {
    popQueryFetchPlan(queryFetchPlanUsed);
  }
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

/**
 * Execute a query that returns a single result.
 */
public X getSingleResult() {
  _em.assertNotCloseInvoked();
  setHint(QueryHints.HINT_RESULT_COUNT, 1); // for DB2 optimization
  boolean queryFetchPlanUsed = pushQueryFetchPlan();
  try {
    List result = getResultList();
    if (result == null || result.isEmpty())
      throw new NoResultException(_loc.get("no-result", getQueryString())
          .getMessage());
    if (result.size() > 1)
      throw new NonUniqueResultException(_loc.get("non-unique-result",
          getQueryString(), result.size()).getMessage());
    try {
      return (X)result.get(0);
    } catch (Exception e) {
      throw new NoResultException(_loc.get("no-result", getQueryString())
        .getMessage());
    }
  } finally {
    popQueryFetchPlan(queryFetchPlanUsed);
  }
}

相关文章

微信公众号

最新文章

更多