• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AliasToBeanResultTransformer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.hibernate.transform.AliasToBeanResultTransformer的典型用法代码示例。如果您正苦于以下问题:Java AliasToBeanResultTransformer类的具体用法?Java AliasToBeanResultTransformer怎么用?Java AliasToBeanResultTransformer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AliasToBeanResultTransformer类属于org.hibernate.transform包,在下文中一共展示了AliasToBeanResultTransformer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: transformToGisFeatureDistance

import org.hibernate.transform.AliasToBeanResultTransformer; //导入依赖的package包/类
/**
 * Transform to bean. See bug
 * http://opensource.atlassian.com/projects/hibernate/browse/HHH-2463
 * 
 * @param aliasList
 *                the alias list
 * @param resultList
 *                the result list
 * 
 * @return the list of GisFeatureDistance
 */
//TODO tests zip test
public static List<GisFeatureDistance> transformToGisFeatureDistance(String aliasList[], List<?> resultList, Map<Long, Set<String>> featureIdToZipCodesMap,Class clazz) {
	List<GisFeatureDistance> results = new ArrayList<GisFeatureDistance>();
	if (aliasList != null && !resultList.isEmpty()) {
		ResultTransformer tr = new AliasToBeanResultTransformer(GisFeatureDistance.class);
		Iterator<?> it = resultList.iterator();
		Object[] obj;
		GisFeatureDistance gisFeatureDistance;
		while (it.hasNext()) {
			obj = (Object[]) it.next();
			gisFeatureDistance = (GisFeatureDistance) tr.transformTuple(obj, aliasList);
			int indexInList = results.indexOf(gisFeatureDistance);
			if (indexInList == -1) {
			    gisFeatureDistanceFactory.updateFields(gisFeatureDistance,clazz);
				results.add(gisFeatureDistance);
				if (featureIdToZipCodesMap != null){
				    gisFeatureDistance.setZipCodes(featureIdToZipCodesMap.get(gisFeatureDistance.getId()));
				}
			}
		}
	}

	return results;
}
 
开发者ID:gisgraphy,项目名称:gisgraphy,代码行数:36,代码来源:ResultTransformerUtil.java


示例2: transformToStreetDistance

import org.hibernate.transform.AliasToBeanResultTransformer; //导入依赖的package包/类
/**
 * Transform to bean. See bug
 * http://opensource.atlassian.com/projects/hibernate/browse/HHH-2463
 * 
 * @param aliasList
 *                the alias list
 * @param resultList
 *                the result list
 * 
 * @return the list of {@link StreetDistance}
 */
public static List<StreetDistance> transformToStreetDistance(String aliasList[], List<?> resultList) {
	List<StreetDistance> transformList = new ArrayList<StreetDistance>();
	if (aliasList != null && !resultList.isEmpty()) {
		AliasToBeanResultTransformer tr = new AliasToBeanResultTransformer(StreetDistance.class);
		Iterator<?> it = resultList.iterator();
		Object[] obj;
		while (it.hasNext()) {
			obj = (Object[]) it.next();
			StreetDistance streetDistance = (StreetDistance) tr.transformTuple(obj, aliasList);
			streetDistance.updateFields();
			transformList.add(streetDistance);
		}
	}
	return transformList;
}
 
开发者ID:gisgraphy,项目名称:gisgraphy,代码行数:27,代码来源:ResultTransformerUtil.java


示例3: getPost

import org.hibernate.transform.AliasToBeanResultTransformer; //导入依赖的package包/类
private PostWithXminAndXmax getPost(EntityManager entityManager, Integer id) {
    List<PostWithXminAndXmax> result = (List<PostWithXminAndXmax>) entityManager.createNativeQuery(
        "SELECT " +
        "    id, title, CAST(xmin AS text), CAST(xmax AS text) " +
        "FROM Post " +
        "WHERE id = :id")
    .setParameter("id", id)
    .unwrap(Query.class)
    .setResultTransformer(new AliasToBeanResultTransformer(PostWithXminAndXmax.class))
    .getResultList();
    return !result.isEmpty() ? result.get(0) : null;
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:13,代码来源:MVCCPostgreSQLTest.java


示例4: filtrarPorTexto

import org.hibernate.transform.AliasToBeanResultTransformer; //导入依赖的package包/类
@Override
public ArrayList<EntidadAbstracta> filtrarPorTexto(String text) {
    AbstractHibernateDAO dummy = new AbstractHibernateDAO(){};

    ArrayList<FamiliaEquipo> listaResultado = new ArrayList<FamiliaEquipo>();

    try
    {
        dummy.iniciaOperacion();
        Query query = dummy.getSession().createSQLQuery(
                "SELECT distinct f.* , " +
                "(select valor from precio_historico "
                + "where familia_id = f.id and tipo_id = 1 and fechaBaja is null "
                + "order by id desc limit 1) as valorPosesion, "
                + "(select valor from precio_historico "
                + "where familia_id = f.id and tipo_id = 2 and fechaBaja is null "
                + "order by id desc limit 1) as valorUtilizacion FROM familia_equipo f "
                + "left join precio_historico ph on ph.familia_id = f.id "
                + "where f.nombre like '%"+ text +"%' ").setResultTransformer(new AliasToBeanResultTransformer(FamiliaEquipoBean.class));
        
        for(FamiliaEquipoBean a: (List<FamiliaEquipoBean>)query.list()) {
            listaResultado.add(a.convert2FamiliaEquipo());
        }
             
    }
    catch (HibernateException he)
    {
        dummy.manejaExcepcion(he);
    }
    finally
    {
        dummy.terminaOperacion();
    }
    ArrayList<EntidadAbstracta> list1 = new ArrayList<EntidadAbstracta>(listaResultado);
    return list1;
}
 
开发者ID:infoINGenieria,项目名称:zprojects,代码行数:37,代码来源:FamiliaEquipoDAO.java


示例5: findByStrCodeUp

import org.hibernate.transform.AliasToBeanResultTransformer; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public List<OrganizationPaginationBean> findByStrCodeUp(String strCodeUp) throws ServiceException {
    if (StringUtils.isEmpty(strCodeUp)) {
           throw new IllegalArgumentException("The organization's code must not be null or empty");
       }
    
    final Session session = HibernateSessionManager.getSession();
	Transaction tx = null;
    
	List<OrganizationPaginationBean> organizations = new ArrayList<OrganizationPaginationBean>();
       try {
       	tx = session.beginTransaction();
       	Criteria criteria = repository.getCriteria(session, Organization.class)
           		.setProjection(Projections.projectionList()
           				.add( Projections.property("strCode").as("strCode"))
           	            .add( Projections.property("strNameR").as("strNameR"))
						.add( Projections.property("comName").as("comName")))
				.add(Restrictions.eq("strCodeUp", strCodeUp))
				.add(Restrictions.eq("delKbn", Constants.STATUS_ACTIVE))
				.addOrder(Order.asc("strCode"))
				.setResultTransformer(new AliasToBeanResultTransformer(OrganizationPaginationBean.class));
       	organizations = criteria.list();
       	// Release transaction
       	tx.commit();
		if (CollectionUtils.isEmpty(organizations)) {
			throw new ObjectNotFoundException("Could not find any Organization with strCodeUp " + strCodeUp);
		}
       } catch (HibernateException ex) {
       	if (tx != null) {
       		tx.rollback();
       	}
           throw new ServiceException("An exception occured while finding Organization list with strCodeUp " + strCodeUp, ex);
       } finally {
       	HibernateSessionManager.closeSession(session);
       }
       return organizations;
}
 
开发者ID:dgks0n,项目名称:Harvest-JP,代码行数:40,代码来源:OrganizationServiceImpl.java


示例6: process

import org.hibernate.transform.AliasToBeanResultTransformer; //导入依赖的package包/类
/**
 * @param request
 * @return
 * @see edu.utah.further.core.chain.AbstractRequestHandler#process(edu.utah.further.core.api.chain.ChainRequest)
 * @see http://opensource.atlassian.com/projects/hibernate/browse/HHH-817
 */
@Override
public boolean process(final ChainRequest request)
{
	final HibernateExecReq executionReq = new HibernateExecReq(request);

	// Validate required input
	final GenericCriteria hibernateCriteria = executionReq.getResult();
	notNull(hibernateCriteria, "Expected Hibernate criteria");

	final Class<? extends PersistentEntity<?>> domainClass = executionReq
			.getRootEntity();
	final Class<? extends PersistentEntity<?>> entityClass = dao
			.getEntityClass(domainClass);

	notNull(entityClass, "Expected root entity class");

	final SessionFactory sessionFactory = executionReq.getSessionFactory();
	notNull(sessionFactory, "Expected SessionFactory");

	final ClassMetadata classMetadata = sessionFactory.getClassMetadata(entityClass);
	final String identifierName = classMetadata.getIdentifierPropertyName();
	final Type identifierType = classMetadata.getIdentifierType();

	// A hack to obtain projections out of the critieria by casting to the Hibernate
	// implementation. TODO: improve adapter to do that via interface access
	final ProjectionList projectionList = Projections.projectionList();
	final Projection existingProjection = ((CriteriaImpl) hibernateCriteria
			.getHibernateCriteria()).getProjection();

	if (existingProjection != null && !overrideExistingProjection)
	{
		return false;
	}

	if (identifierType.isComponentType())
	{
		final ComponentType componentType = (ComponentType) identifierType;
		final String[] idPropertyNames = componentType.getPropertyNames();

		// Add distinct to the first property
		projectionList.add(
				Projections.distinct(Property.forName(identifierName
						+ PROPERTY_SCOPE_CHAR + idPropertyNames[0])),
				idPropertyNames[0]);

		// Add the remaining properties to the projection list
		for (int i = 1; i < idPropertyNames.length; i++)
		{
			projectionList.add(
					Property.forName(identifierName + PROPERTY_SCOPE_CHAR
							+ idPropertyNames[i]), idPropertyNames[i]);
		}

		hibernateCriteria.setProjection(projectionList);
		hibernateCriteria.setResultTransformer(new AliasToBeanResultTransformer(
				ReflectionUtils.findField(entityClass, identifierName).getType()));
	}
	else
	{
		// 'this' required to avoid HHH-817
		projectionList.add(Projections.distinct(Property.forName(THIS_CONTEXT
				+ identifierName)));
		hibernateCriteria.setProjection(projectionList);
	}

	executionReq.setResult(hibernateCriteria);

	return false;
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:76,代码来源:HibernateDistinctIdExecutor.java


示例7: propertyFind

import org.hibernate.transform.AliasToBeanResultTransformer; //导入依赖的package包/类
/**
 * Queries the database for a result set which consists of only a single property value for each of all rows that match the criteria within the table.
 *
 * @param model        the model class which represents the table
 * @param criteria     the criteria
 * @param propertyType the type of the property
 * @param property     the property name
 * @param <T>          the type of the model which represents the table
 * @param <V>          the type of the property value within the result set
 * @return a list of values for the specified property
 */
public <T, V> List<V> propertyFind(Class<T> model, Criteria criteria, Class<V> propertyType, String property) {
    if (model == null || propertyType == null || property == null)
        throw new IllegalArgumentException();
    org.hibernate.Criteria c = session.createCriteria(model);
    if (criteria != null)
        criteria.accept(c);
    c.setProjection(Projections.property(property));
    c.setResultTransformer(new AliasToBeanResultTransformer(propertyType));
    return c.list();
}
 
开发者ID:iancaffey,项目名称:vigor,代码行数:22,代码来源:SqlClient.java



注:本文中的org.hibernate.transform.AliasToBeanResultTransformer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BlockType类代码示例发布时间:2022-05-22
下一篇:
Java Storage类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap