org.hibernate.Query.getQueryString()方法的使用及代码示例

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

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

Query.getQueryString介绍

[英]Get the query string.
[中]获取查询字符串。

代码示例

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

hqlQuery.getQueryString(),
false,
getLoadQueryInfluencers().getEnabledFilters()

代码示例来源:origin: zstackio/zstack

@Transactional(readOnly = true)
  long count() {
    String jpql = build(true);
    Query q = dbf.getEntityManager().createQuery(jpql);
    if (logger.isTraceEnabled()) {
      org.hibernate.Query hq = q.unwrap(org.hibernate.Query.class);
      logger.trace(hq.getQueryString());
    }
    setQueryValue(q, root);
    return (Long) q.getSingleResult();
  }
}

代码示例来源:origin: zstackio/zstack

@Transactional(readOnly = true)
List query() {
  if (msg.isFieldQuery()) {
    validateFields();
  }
  String jpql = build(false);
  Query q = msg.isFieldQuery() ? dbf.getEntityManager().createQuery(jpql, Tuple.class) : dbf.getEntityManager().createQuery(jpql);
  if (logger.isTraceEnabled()) {
    org.hibernate.Query hq = q.unwrap(org.hibernate.Query.class);
    logger.trace(hq.getQueryString());
  }
  setQueryValue(q, root);
  if (msg.getLimit() != null) {
    q.setMaxResults(msg.getLimit());
  }
  if (msg.getStart() != null) {
    q.setFirstResult(msg.getStart());
  }
  List vos = q.getResultList();
  if (msg.isFieldQuery()) {
    return convertFieldsTOPartialInventories(vos);
  } else {
    return convertVOsToInventories(vos);
  }
}

代码示例来源:origin: bonitasoft/bonita-engine

@Override
public void setTenantId(Query query, long tenantId) {
  if (query.getQueryString().contains(":tenantId")) {
    query.setParameter("tenantId", tenantId);
  }
}

代码示例来源:origin: bonitasoft/bonita-engine

@Override
public void setTenantId(Query query, long tenantId) {
  if (query.getQueryString().contains(":tenantId")) {
    query.setParameter("tenantId", tenantId);
  }
}

代码示例来源:origin: org.bedework/bw-util-hibernate

@Override
public String getQueryString() throws HibException {
 if (q == null) {
  return "*** no query ***";
 }
 try {
  return q.getQueryString();
 } catch (Throwable t) {
  handleException(t);
  return null;
 }
}

代码示例来源:origin: org.sakaiproject.sitestats/sitestats-impl

public Object doInHibernate(Session session) throws HibernateException, SQLException {
    String hql = "FROM SitePresenceTotalImpl st WHERE st.siteId = :siteId";
    Query q = session.createQuery(hql);
    q.setString("siteId", siteId);
    LOG.debug("getPresenceTotalsForSite(): " + q.getQueryString());
    return q.list();
  }
};

代码示例来源:origin: bonitasoft/bonita-engine

public QueryBuilder createQueryBuilderFor(Query query, Class<? extends PersistentObject> entityType, OrderByBuilder orderByBuilder,
    Map<String, String> classAliasMappings,
    Map<String, Class<? extends PersistentObject>> interfaceToClassMapping, char likeEscapeCharacter) {
  if (query instanceof SQLQuery) {
    return new SQLQueryBuilder(query.getQueryString(), vendor, entityType, orderByBuilder, classAliasMappings, interfaceToClassMapping,
        likeEscapeCharacter);
  } else {
    return new HQLQueryBuilder(query.getQueryString(), orderByBuilder, classAliasMappings, interfaceToClassMapping, likeEscapeCharacter);
  }
}

代码示例来源:origin: bonitasoft/bonita-engine

public QueryBuilder createQueryBuilderFor(Query query, Class<? extends PersistentObject> entityType, OrderByBuilder orderByBuilder,
    Map<String, String> classAliasMappings,
    Map<String, Class<? extends PersistentObject>> interfaceToClassMapping, char likeEscapeCharacter) {
  if (query instanceof SQLQuery) {
    return new SQLQueryBuilder(query.getQueryString(), vendor, entityType, orderByBuilder, classAliasMappings, interfaceToClassMapping,
        likeEscapeCharacter);
  } else {
    return new HQLQueryBuilder(query.getQueryString(), orderByBuilder, classAliasMappings, interfaceToClassMapping, likeEscapeCharacter);
  }
}

代码示例来源:origin: oasp/oasp4j

/**
 * {@inheritDoc}
 */
@Override
public String getObject() throws Exception {
 return this.entityManager.createNamedQuery(this.queryName).unwrap(Query.class).getQueryString();
}

代码示例来源:origin: Blazebit/blaze-persistence

@Override
public String expandParameterLists(SessionImplementor session, org.hibernate.Query hibernateQuery, Map<String, TypedValue> namedParamsCopy) {
  String query = hibernateQuery.getQueryString();
  ParameterMetadata parameterMetadata = getParameterMetadata(hibernateQuery);
  Iterator<Map.Entry<String, TypedValue>> iter = getNamedParamLists(hibernateQuery).entrySet().iterator();
  while (iter.hasNext()) {
    Map.Entry<String, TypedValue> me = iter.next();
    query = expandParameterList(session, parameterMetadata, query, (String) me.getKey(), (TypedValue) me.getValue(), namedParamsCopy);
  }
  return query;
}

代码示例来源:origin: com.blazebit/blaze-persistence-integration-hibernate-4.3

@Override
public String expandParameterLists(SessionImplementor session, org.hibernate.Query hibernateQuery, Map<String, TypedValue> namedParamsCopy) {
  String query = hibernateQuery.getQueryString();
  ParameterMetadata parameterMetadata = getParameterMetadata(hibernateQuery);
  Iterator<Map.Entry<String, TypedValue>> iter = getNamedParamLists(hibernateQuery).entrySet().iterator();
  while (iter.hasNext()) {
    Map.Entry<String, TypedValue> me = iter.next();
    query = expandParameterList(session, parameterMetadata, query, (String) me.getKey(), (TypedValue) me.getValue(), namedParamsCopy);
  }
  return query;
}

代码示例来源:origin: Blazebit/blaze-persistence

@Override
public String expandParameterLists(SessionImplementor session, org.hibernate.Query hibernateQuery, Map<String, TypedValue> namedParamsCopy) {
  String query = hibernateQuery.getQueryString();
  ParameterMetadata parameterMetadata = getParameterMetadata(hibernateQuery);
  Iterator<Map.Entry<String, TypedValue>> iter = getNamedParamLists(hibernateQuery).entrySet().iterator();
  while (iter.hasNext()) {
    Map.Entry<String, TypedValue> me = iter.next();
    query = expandParameterList(session, parameterMetadata, query, (String) me.getKey(), (TypedValue) me.getValue(), namedParamsCopy);
  }
  return query;
}

代码示例来源:origin: Blazebit/blaze-persistence

@Override
public String expandParameterLists(SessionImplementor session, org.hibernate.Query hibernateQuery, Map<String, TypedValue> namedParamsCopy) {
  String query = hibernateQuery.getQueryString();
  ParameterMetadata parameterMetadata = getParameterMetadata(hibernateQuery);
  Iterator<Map.Entry<String, TypedValue>> iter = getNamedParamLists(hibernateQuery).entrySet().iterator();
  while (iter.hasNext()) {
    Map.Entry<String, TypedValue> me = iter.next();
    query = expandParameterList(session, parameterMetadata, query, (String) me.getKey(), (TypedValue) me.getValue(), namedParamsCopy);
  }
  return query;
}

代码示例来源:origin: com.blazebit/blaze-persistence-integration-hibernate-5

@Override
public String expandParameterLists(SessionImplementor session, org.hibernate.Query hibernateQuery, Map<String, TypedValue> namedParamsCopy) {
  String query = hibernateQuery.getQueryString();
  ParameterMetadata parameterMetadata = getParameterMetadata(hibernateQuery);
  Iterator<Map.Entry<String, TypedValue>> iter = getNamedParamLists(hibernateQuery).entrySet().iterator();
  while (iter.hasNext()) {
    Map.Entry<String, TypedValue> me = iter.next();
    query = expandParameterList(session, parameterMetadata, query, (String) me.getKey(), (TypedValue) me.getValue(), namedParamsCopy);
  }
  return query;
}

代码示例来源:origin: Blazebit/blaze-persistence

private HQLQueryPlan createQueryPlan(SessionFactoryImplementor sfi, Query query) {
  org.hibernate.Query hibernateQuery = query.unwrap(org.hibernate.Query.class);
  String queryString = hibernateQuery.getQueryString();
  return new HQLQueryPlan(queryString, false, Collections.EMPTY_MAP, sfi);
}

代码示例来源:origin: Blazebit/blaze-persistence

@Override
public String expandParameterLists(SessionImplementor session, org.hibernate.Query hibernateQuery, Map<String, TypedValue> namedParamsCopy) {
  QueryParameterBindingsImpl queryParameterBindings = hibernateQuery.unwrap(QueryParameterBindingsImpl.class);
  SharedSessionContractImplementor producer = (SharedSessionContractImplementor) ((QueryImplementor<?>) hibernateQuery).getProducer();
  String query = hibernateQuery.getQueryString();
  query = queryParameterBindings.expandListValuedParameters(query, producer);
  return query;
}

代码示例来源:origin: com.blazebit/blaze-persistence-integration-hibernate-6.0

@Override
public String expandParameterLists(SessionImplementor session, org.hibernate.Query hibernateQuery, Map<String, TypedValue> namedParamsCopy) {
  QueryParameterBindingsImpl queryParameterBindings = hibernateQuery.unwrap(QueryParameterBindingsImpl.class);
  SharedSessionContractImplementor producer = (SharedSessionContractImplementor) ((QueryImplementor<?>) hibernateQuery).getProducer();
  String query = hibernateQuery.getQueryString();
  query = queryParameterBindings.expandListValuedParameters(query, producer);
  return query;
}

代码示例来源:origin: com.blazebit/blaze-persistence-integration-hibernate-5.2

@Override
public String expandParameterLists(SessionImplementor session, org.hibernate.Query hibernateQuery, Map<String, TypedValue> namedParamsCopy) {
  QueryParameterBindingsImpl queryParameterBindings = hibernateQuery.unwrap(QueryParameterBindingsImpl.class);
  SharedSessionContractImplementor producer = (SharedSessionContractImplementor) ((QueryImplementor<?>) hibernateQuery).getProducer();
  String query = hibernateQuery.getQueryString();
  query = queryParameterBindings.expandListValuedParameters(query, producer);
  return query;
}

代码示例来源:origin: Blazebit/blaze-persistence

@Override
public String expandParameterLists(SessionImplementor session, org.hibernate.Query hibernateQuery, Map<String, TypedValue> namedParamsCopy) {
  QueryParameterBindingsImpl queryParameterBindings = hibernateQuery.unwrap(QueryParameterBindingsImpl.class);
  SharedSessionContractImplementor producer = (SharedSessionContractImplementor) ((QueryImplementor<?>) hibernateQuery).getProducer();
  String query = hibernateQuery.getQueryString();
  // NOTE: In Hibernate 5.3.0.CR1 this is call causes a side effect which is why this is essentially unusable for us
  query = queryParameterBindings.expandListValuedParameters(query, producer);
  return query;
}

相关文章