本文整理了Java中org.hibernate.Query.setResultTransformer
方法的一些代码示例,展示了Query.setResultTransformer
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setResultTransformer
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setResultTransformer
[英]Set a strategy for handling the query results. This can be used to change "shape" of the query result.
[中]设置处理查询结果的策略。这可用于更改查询结果的“形状”。
代码示例来源:origin: stackoverflow.com
Query query=session.createSQLQuery("your query");
query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
List<Map<String,Object>> aliasToValueMapList=query.list();
代码示例来源:origin: hibernate/hibernate-orm
hqlQuery.setResultTransformer( tupleTransformer );
代码示例来源:origin: hibernate/hibernate-orm
t = s.beginTransaction();
Query sqlQuery = s.getNamedQuery("EmploymentAndPerson");
sqlQuery.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
list = sqlQuery.list();
assertEquals(1,list.size() );
t = s.beginTransaction();
sqlQuery = s.getNamedQuery( "organizationreturnproperty" );
sqlQuery.setResultTransformer( Transformers.ALIAS_TO_ENTITY_MAP );
list = sqlQuery.list();
assertEquals( 2,list.size() );
代码示例来源:origin: hibernate/hibernate-orm
Transaction t = session.beginTransaction();
try {
getSelectNewQuery( session ).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
fail("'select new' together with a resulttransformer should result in error!");
getSelectNewQuery( session ).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).iterate();
fail("'select new' together with a resulttransformer should result in error!");
getSelectNewQuery( session ).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).scroll();
fail("'select new' together with a resulttransformer should result in error!");
代码示例来源:origin: bill1012/AdminEAP
public List<Map> findMap(String hql) {
Query query = this.getCurrentSession().createQuery(hql);
query.setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP);
return query.list();
}
代码示例来源:origin: bill1012/AdminEAP
@SuppressWarnings("unchecked")
public List<Map<String, Object>> findMapBySql(String sql, int page, int rows) {
SQLQuery sqlQuery = this.getCurrentSession().createSQLQuery(sql);
return sqlQuery.setFirstResult((page - 1) * rows).setMaxResults(rows).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
}
代码示例来源:origin: bill1012/AdminEAP
@SuppressWarnings("unchecked")
public List<Map<String, Object>> findMapBySql(String sql, Map<String, Object> params, int page, int rows) {
SQLQuery sqlQuery = this.getCurrentSession().createSQLQuery(sql);
sqlQuery=getSqlQueryByMap(sqlQuery,params);
return sqlQuery.setFirstResult((page - 1) * rows).setMaxResults(rows).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
}
代码示例来源:origin: bill1012/AdminEAP
@Override
public List findMapBySql(String sql, int firstResult, int maxResult, Object[] params, Type[] types, Class clazz) {
if (clazz != null)
return this.getCurrentSession().createSQLQuery(sql).setParameters(params, types).setFirstResult(firstResult)
.setMaxResults(maxResult).setResultTransformer(Transformers.aliasToBean(clazz)).list();
else
return this.getCurrentSession().createSQLQuery(sql).setParameters(params, types).setFirstResult(firstResult)
.setMaxResults(maxResult).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
}
代码示例来源:origin: slyak/spring-data-jpa-extra
public static <C> Query transform(Query query, Class<C> clazz) {
ResultTransformer transformer;
if (Map.class.isAssignableFrom(clazz)) {
transformer = Transformers.ALIAS_TO_ENTITY_MAP;
} else if (Number.class.isAssignableFrom(clazz) || clazz.isPrimitive() || String.class.isAssignableFrom(clazz) ||
Date.class.isAssignableFrom(clazz)) {
transformer = transformerCache.computeIfAbsent(clazz, SmartTransformer::new);
} else {
transformer = transformerCache.computeIfAbsent(clazz, BeanTransformerAdapter::new);
}
return query.setResultTransformer(transformer);
}
代码示例来源:origin: debop/hibernate-redis
@Override
public long count(Query query, HibernateParameter... parameters) {
return (Long) HibernateTool.setParameters(query, parameters)
.setResultTransformer(CriteriaSpecification.PROJECTION)
.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY)
.uniqueResult();
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-deskmanager
public boolean geodeskIdExists(String publicId) {
Query q = factory.getCurrentSession().createQuery("select id from Geodesk l WHERE l.geodeskId = :id");
q.setParameter("id", publicId);
q.setResultTransformer(DistinctRootEntityResultTransformer.INSTANCE);
Object result = q.uniqueResult();
return (result != null);
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-deskmanager
public Geodesk getGeodeskByPublicIdInternal(String id) {
if (geodeskExists(id)) {
Query q = factory.getCurrentSession().createQuery(
"FROM Geodesk l WHERE l.geodeskId = :id AND " + "l.deleted = false AND " + "l.active = true AND "
+ "l.blueprint.geodesksActive = true");
q.setParameter("id", id);
q.setResultTransformer(DistinctRootEntityResultTransformer.INSTANCE);
return (Geodesk) q.uniqueResult();
} else {
return null;
}
}
代码示例来源:origin: com.querydsl/querydsl-jpa
@Override
public boolean transform(Query query, FactoryExpression<?> projection) {
if (query instanceof HibernateQuery) {
ResultTransformer transformer = new FactoryExpressionTransformer(projection);
((HibernateQuery) query).getHibernateQuery().setResultTransformer(transformer);
return true;
} else {
return false;
}
}
代码示例来源:origin: org.opensingular/singular-requirement-module
public Actor retrieveByUserCod(String userName) {
if (userName == null) {
return null;
}
Query query = getSession().createSQLQuery(
"select a.CO_ATOR as \"cod\", a.CO_USUARIO as \"codUsuario\", a.NO_ATOR as \"nome\", a.DS_EMAIL as \"email\" " +
" FROM " + Constants.SCHEMA + ".VW_ATOR a " +
" WHERE UPPER(rtrim(ltrim(a.CO_USUARIO))) = :codUsuario");
query.setParameter("codUsuario", userName.toUpperCase());
query.setResultTransformer(new FindActorByUserCodResultTransformer());
return (Actor) query.uniqueResult();
}
代码示例来源:origin: org.opensingular/singular-requirement-commons
public Actor retrieveByUserCod(String userName) {
if (userName == null) {
return null;
}
Query query = getSession().createSQLQuery(
"select a.CO_ATOR as \"cod\", a.CO_USUARIO as \"codUsuario\", a.NO_ATOR as \"nome\", a.DS_EMAIL as \"email\" " +
" FROM " + Constants.SCHEMA + ".VW_ATOR a " +
" WHERE UPPER(rtrim(ltrim(a.CO_USUARIO))) = :codUsuario");
query.setParameter("codUsuario", userName.toUpperCase());
query.setResultTransformer(new FindActorByUserCodResultTransformer());
return (Actor) query.uniqueResult();
}
代码示例来源:origin: org.ow2.bonita/bonita-server
@Override
@SuppressWarnings("unchecked")
public List<EventCouple> getMessageEventCouples() {
final Query query = getSession().getNamedQuery("getMessageEventCouples");
query.setResultTransformer(Transformers.aliasToBean(EventCouple.class));
return formatList(query.list());
}
代码示例来源:origin: org.ow2.bonita/bonita-server
@Override
@SuppressWarnings("unchecked")
public List<EventCouple> getCorrelationKeyMessageEventCouples(final int maxCouples) {
final Query query = getSession().getNamedQuery("getCorrelationKeyMessageEventCouples");
query.setMaxResults(maxCouples);
query.setResultTransformer(Transformers.aliasToBean(EventCouple.class));
return formatList(query.list());
}
代码示例来源:origin: org.opensingular/singular-requirement-commons
private List<Map<String, Serializable>> quickSearchMap(RequirementSearchContext query) {
return makeRequirementSearchQuery(query)
.setFirstResult(query.getQuickFilter().getFirst())
.setMaxResults(query.getQuickFilter().getCount())
.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE)
.list();
}
代码示例来源:origin: org.opensingular/server-commons
public List<PetitionDTO> quickSearch(QuickFilter filtro, List<String> siglasProcesso, List<String> formNames) {
final Query query = createQuery(filtro, siglasProcesso, false, formNames);
query.setFirstResult(filtro.getFirst());
query.setMaxResults(filtro.getCount());
query.setResultTransformer(new AliasToBeanResultTransformer(getResultClass()));
return query.list();
}
代码示例来源:origin: org.opensingular/singular-server-commons
private List<Map<String, Serializable>> quickSearchMap(RequirementSearchContext query) {
return makeRequirementSearchQuery(query)
.setFirstResult(query.getQuickFilter().getFirst())
.setMaxResults(query.getQuickFilter().getCount())
.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE)
.list();
}
内容来源于网络,如有侵权,请联系作者删除!