List of usage examples for org.hibernate Query setResultTransformer
@Deprecated Query<R> setResultTransformer(ResultTransformer transformer);
From source file:br.com.gvt.eng.vod.dao.AssetDAO.java
public List<OnDemandContentVO> findTop50() { StringBuilder aux = new StringBuilder( "select a.assetId, count(*) as total from IpvodPurchase p join p.ipvodAsset a group by a.assetId order by total desc"); Query query = getSession().createQuery(String.valueOf(aux)); query.setFirstResult(0);//from w w w .j a v a 2 s . c om query.setMaxResults(50); @SuppressWarnings("unchecked") List<Object[]> list = query.list(); List<OnDemandContentVO> vos = new ArrayList<OnDemandContentVO>(); for (Object[] obj : list) { StringBuilder hql = new StringBuilder("select "); hql.append("a.title as title, "); hql.append("a.originalTitle as originalTitle, "); hql.append("'UNKNOWN' as genre, "); hql.append("c.description as category, "); hql.append("a.subtitles as subtitle, "); hql.append("a.country as country, "); hql.append("sc.description as subCategory, "); hql.append("a.assetId as assetId, "); hql.append("a.creationDate as creationDate, "); hql.append("a.description as description, "); hql.append("a.director as director, "); hql.append("a.actors as actors, "); hql.append("a.episode as episode, "); hql.append("a.billingID as billingID, "); hql.append("a.episodeName as episodeName, "); hql.append("a.licenseWindowEnd as licenseWindowEnd, "); hql.append("a.licenseWindowStart as licenseWindowStart, "); hql.append("a.price as price, "); hql.append("a.releaseYear as releaseYear, "); hql.append("a.season as season, "); hql.append("a.languages as languages, "); hql.append("a.assetInfo as assetInfo, "); hql.append("r.rating as rating, "); hql.append("r.adult as isAdult, "); hql.append("a.totalTime as totalTime, "); hql.append("a.product as product, "); hql.append("a.screenFormat as screenFormat, "); hql.append("a.audioType as audioType, "); hql.append("a.canResume as canResume, "); hql.append("a.isHD as isHD, "); hql.append("a.isRevised as isRevised, "); hql.append("a.fileSize as fileSize, "); hql.append("a.checksum as checksum, "); hql.append("a.bitrate as bitrate, "); hql.append("a.titleAlternative as titleAlternative, "); hql.append("at.description as assetType, "); hql.append("cp.providerId as contentProvider "); hql.append( "from IpvodAsset as a left join a.ipvodCategory1 c left join a.ipvodCategory2 sc left join a.ipvodAssetType at left join a.ipvodContentProvider cp left join a.rating r "); hql.append("where a.assetId = :assetId order by a.title asc "); query = getSession().createQuery(String.valueOf(hql)); query.setParameter("assetId", obj[0]); query.setResultTransformer(new AliasToBeanResultTransformer(OnDemandContentVO.class)); OnDemandContentVO vo = (OnDemandContentVO) query.uniqueResult(); vo.setOrder(new Long(list.lastIndexOf(obj) + 1)); vos.add(list.lastIndexOf(obj), vo); } return vos; }
From source file:br.com.gvt.eng.vod.dao.AssetDAO.java
@SuppressWarnings("unchecked") public List<OnDemandContentVO> findByGenre(Long genreId) { StringBuilder hql = new StringBuilder("select "); hql.append("a.title as title, "); hql.append("a.originalTitle as originalTitle, "); hql.append("'UNKNOWN' as genre, "); hql.append("c.description as category, "); hql.append("a.subtitles as subtitle, "); hql.append("a.country as country, "); hql.append("sc.description as subCategory, "); hql.append("a.assetId as assetId, "); hql.append("a.creationDate as creationDate, "); hql.append("a.description as description, "); hql.append("a.director as director, "); hql.append("a.actors as actors, "); hql.append("a.episode as episode, "); hql.append("a.billingID as billingID, "); hql.append("a.episodeName as episodeName, "); hql.append("a.licenseWindowEnd as licenseWindowEnd, "); hql.append("a.licenseWindowStart as licenseWindowStart, "); hql.append("a.price as price, "); hql.append("a.releaseYear as releaseYear, "); hql.append("a.season as season, "); hql.append("a.languages as languages, "); hql.append("a.assetInfo as assetInfo, "); hql.append("r.rating as rating, "); hql.append("r.adult as isAdult, "); hql.append("a.totalTime as totalTime, "); hql.append("a.product as product, "); hql.append("a.screenFormat as screenFormat, "); hql.append("a.audioType as audioType, "); hql.append("a.canResume as canResume, "); hql.append("a.isHD as isHD, "); hql.append("a.isRevised as isRevised, "); hql.append("a.fileSize as fileSize, "); hql.append("a.checksum as checksum, "); hql.append("a.bitrate as bitrate, "); hql.append("a.titleAlternative as titleAlternative, "); hql.append("at.description as assetType, "); hql.append("cp.providerId as contentProvider "); hql.append(//from w w w .java 2 s . com "from IpvodAsset as a left join a.ipvodCategory1 c left join a.ipvodCategory2 sc left join a.ipvodAssetType at left join a.ipvodContentProvider cp left join a.rating r "); hql.append("where c.categoryId = :genre order by a.title asc "); Query query = getSession().createQuery(String.valueOf(hql)); query.setParameter("genre", genreId); query.setResultTransformer(new AliasToBeanResultTransformer(OnDemandContentVO.class)); return query.list(); }
From source file:br.com.gvt.eng.vod.dao.AssetDAO.java
@SuppressWarnings("unchecked") public List<OnDemandContentVO> findHighlights() { StringBuilder hql = new StringBuilder("select "); hql.append("h.order as order, "); hql.append("a.title as title, "); hql.append("a.originalTitle as originalTitle, "); hql.append("'UNKNOWN' as genre, "); hql.append("c.description as category, "); hql.append("a.subtitles as subtitle, "); hql.append("a.country as country, "); hql.append("sc.description as subCategory, "); hql.append("a.assetId as assetId, "); hql.append("a.creationDate as creationDate, "); hql.append("a.description as description, "); hql.append("a.director as director, "); hql.append("a.actors as actors, "); hql.append("a.episode as episode, "); hql.append("a.billingID as billingID, "); hql.append("a.episodeName as episodeName, "); hql.append("a.licenseWindowEnd as licenseWindowEnd, "); hql.append("a.licenseWindowStart as licenseWindowStart, "); hql.append("a.price as price, "); hql.append("a.releaseYear as releaseYear, "); hql.append("a.season as season, "); hql.append("a.languages as languages, "); hql.append("a.assetInfo as assetInfo, "); hql.append("r.rating as rating, "); hql.append("r.adult as isAdult, "); hql.append("a.totalTime as totalTime, "); hql.append("a.product as product, "); hql.append("a.screenFormat as screenFormat, "); hql.append("a.audioType as audioType, "); hql.append("a.canResume as canResume, "); hql.append("a.isHD as isHD, "); hql.append("a.isRevised as isRevised, "); hql.append("a.fileSize as fileSize, "); hql.append("a.checksum as checksum, "); hql.append("a.bitrate as bitrate, "); hql.append("a.titleAlternative as titleAlternative, "); hql.append("at.description as assetType, "); hql.append("cp.providerId as contentProvider "); hql.append(/*from ww w . j a v a2s . com*/ "from IpvodHighlight as h join h.asset a left join a.ipvodCategory1 c left join a.ipvodCategory2 sc left join a.ipvodAssetType at left join a.ipvodContentProvider cp left join a.rating r "); hql.append("order by order asc "); Query query = getSession().createQuery(String.valueOf(hql)); query.setResultTransformer(new AliasToBeanResultTransformer(OnDemandContentVO.class)); return query.list(); }
From source file:br.com.gvt.eng.vod.dao.AssetDAO.java
@SuppressWarnings("unchecked") public List<OnDemandContentVO> findReleases() { StringBuilder hql = new StringBuilder("select "); hql.append("ir.order as order, "); hql.append("a.title as title, "); hql.append("a.originalTitle as originalTitle, "); hql.append("'UNKNOWN' as genre, "); hql.append("c.description as category, "); hql.append("a.subtitles as subtitle, "); hql.append("a.country as country, "); hql.append("sc.description as subCategory, "); hql.append("a.assetId as assetId, "); hql.append("a.creationDate as creationDate, "); hql.append("a.description as description, "); hql.append("a.director as director, "); hql.append("a.actors as actors, "); hql.append("a.episode as episode, "); hql.append("a.billingID as billingID, "); hql.append("a.episodeName as episodeName, "); hql.append("a.licenseWindowEnd as licenseWindowEnd, "); hql.append("a.licenseWindowStart as licenseWindowStart, "); hql.append("a.price as price, "); hql.append("a.releaseYear as releaseYear, "); hql.append("a.season as season, "); hql.append("a.languages as languages, "); hql.append("a.assetInfo as assetInfo, "); hql.append("r.rating as rating, "); hql.append("r.adult as isAdult, "); hql.append("a.totalTime as totalTime, "); hql.append("a.product as product, "); hql.append("a.screenFormat as screenFormat, "); hql.append("a.audioType as audioType, "); hql.append("a.canResume as canResume, "); hql.append("a.isHD as isHD, "); hql.append("a.isRevised as isRevised, "); hql.append("a.fileSize as fileSize, "); hql.append("a.checksum as checksum, "); hql.append("a.bitrate as bitrate, "); hql.append("a.titleAlternative as titleAlternative, "); hql.append("at.description as assetType, "); hql.append("cp.providerId as contentProvider "); hql.append(/*from ww w. jav a2s .co m*/ "from IpvodRelease as ir join ir.asset a left join a.ipvodCategory1 c left join a.ipvodCategory2 sc left join a.ipvodAssetType at left join a.ipvodContentProvider cp left join a.rating r "); hql.append("order by order asc "); Query query = getSession().createQuery(String.valueOf(hql)); query.setResultTransformer(new AliasToBeanResultTransformer(OnDemandContentVO.class)); return query.list(); }
From source file:br.com.gvt.eng.vod.dao.IngestDAO.java
/** * Busca dados para serem mostrados na tela de revisao Ingestao IPVOD-CMS * //from www . j a va2s .c o m * @return List<IpvodIngestStage> */ @SuppressWarnings("unchecked") public List<IngestVO> findAllDataIngestForRevision(UriInfo uriInfo, IpvodContentProvider ipvodContentProvider) { // HQL dos dados, todos os campos devem ter o mesmo nome dos atributos // no IngestVO StringBuilder hql = new StringBuilder(); hql.append("select "); hql.append("ins.id as idIngest, "); hql.append("ins.stageType.id as stageType, "); hql.append("asset.assetId as assetId, "); hql.append("asset.title as assetTitle, "); hql.append("ins.assetName as assetName, "); hql.append("assetCategory.description as categoryDescription, "); hql.append("assetCategory.categoryId as assetCategoryId, "); hql.append("ins.dtInsert as dtInsertIngest, "); hql.append("ins.dtChange as dtChangeIngest, "); hql.append("cast(ins.result as boolean) as resultOK, "); hql.append("ins.priority as priority, "); hql.append("asset.languages as language, "); hql.append("asset.billingID as billingId, "); hql.append("asset.price as price "); hql.append("from "); hql.append("IpvodIngestStage ins "); hql.append("inner join ins.ipvodAsset as asset "); hql.append("left join ins.ipvodAsset.ipvodCategory1 as assetCategory "); hql.append("where "); hql.append("ins.stageType.id = 7 "); hql.append("and (asset.isRevised is null or asset.isRevised = 0) "); hql.append("and asset.licenseWindowEnd > sysdate "); if (ipvodContentProvider != null) { hql.append(" and asset.ipvodContentProvider.contentProviderId = " + ipvodContentProvider.getContentProviderId()); } if (uriInfo.getQueryParameters().getFirst(IpvodConstants.URLPARAM_NOT_CATEGORIZED) != null) { hql.append(" and asset.ipvodVisualMenuAsset is empty "); } Map<String, Object> parameters = parseUriInfo(uriInfo); Filter filter = (Filter) parameters.get("filters"); if (filter != null && !filter.getRules().isEmpty()) { if (filter.getGroupOp().equals("AND")) { for (FilterRules rule : filter.getRules()) { hql.append( " and upper(" + rule.getField() + ") like '%" + rule.getData().toUpperCase() + "%' "); } } else { StringBuilder orClause = new StringBuilder(); orClause.append(" and ( "); for (int i = 0; i < filter.getRules().size(); i++) { FilterRules rule = filter.getRules().get(i); if (i > 0) { orClause.append(" or "); } orClause.append( " upper(" + rule.getField() + ") like '%" + rule.getData().toUpperCase() + "%' "); } orClause.append(" ) "); hql.append(orClause); } } hql.append(" order by ins.id desc, ins.priority asc"); Query query = getSession().createQuery(String.valueOf(hql)); setPagination(query, uriInfo); query.setResultTransformer(new AliasToBeanResultTransformer(IngestVO.class)); return query.list(); }
From source file:br.com.gvt.eng.vod.dao.IngestDAO.java
/** * Lista dados @IpvodIngestStage/*w w w.j av a 2 s . c om*/ * * @return List<IngestVO> */ @SuppressWarnings("unchecked") public List<IngestVO> findDataIngestBeforePlataform(UriInfo uriInfo, IpvodContentProvider ipvodContentProvider) { // HQL dos dados, todos os campos devem ter o mesmo nome dos atributos // no IngestVO StringBuilder hql = new StringBuilder(); hql.append("select "); hql.append("ins.id as idIngest, "); hql.append("ins.stageType.id as stageType, "); hql.append("ins.assetInfo as assetInfo, "); hql.append("ins.adicionalInfo as adicionalInfo, "); hql.append("asset.assetId as assetId, "); hql.append("asset.title as assetTitle, "); hql.append("ins.assetName as assetName, "); hql.append("ins.dtInsert as dtInsertIngest, "); hql.append("ins.dtChange as dtChangeIngest, "); hql.append("cast(ins.result as boolean) as resultOK, "); hql.append("ins.priority as priority "); hql.append("from "); hql.append("IpvodIngestStage ins "); hql.append("left outer join ins.ipvodAsset as asset "); hql.append("where "); hql.append("ins.stageType.id < 7 "); if (ipvodContentProvider != null) { hql.append(" and asset.ipvodContentProvider.contentProviderId = " + ipvodContentProvider.getContentProviderId()); } Map<String, Object> parameters = parseUriInfo(uriInfo); Filter filter = (Filter) parameters.get("filters"); if (filter != null && !filter.getRules().isEmpty()) { if (filter.getGroupOp().equals("AND")) { for (FilterRules rule : filter.getRules()) { hql.append( " and upper(" + rule.getField() + ") like '%" + rule.getData().toUpperCase() + "%' "); } } else { StringBuilder orClause = new StringBuilder(); orClause.append(" and ( "); for (int i = 0; i < filter.getRules().size(); i++) { FilterRules rule = filter.getRules().get(i); if (i > 0) { orClause.append(" or "); } orClause.append( " upper(" + rule.getField() + ") like '%" + rule.getData().toUpperCase() + "%' "); } orClause.append(" ) "); hql.append(orClause); } } hql.append(" order by ins.id desc, ins.priority asc"); Query query = getSession().createQuery(String.valueOf(hql)); setPagination(query, uriInfo); query.setResultTransformer(new AliasToBeanResultTransformer(IngestVO.class)); return query.list(); }
From source file:br.com.gvt.eng.vod.dao.IngestDAO.java
/** * Lista dados @IpvodBalancerData/*from ww w . j av a2 s .co m*/ * * @param idIngest * @return List<BalancerVO> */ @SuppressWarnings("unchecked") public List<BalancerVO> findData4Balancer(Long idIngest) { // HQL dos dados, todos os campos devem ter o mesmo nome dos atributos // no IngestVO StringBuilder hql = new StringBuilder(); hql.append("select "); hql.append("bad.id as idBalancer, "); hql.append("bad.nameFile as nameFile, "); hql.append("bad.status as statusBalancer, "); hql.append("bad.percentComp as percentCompBalancer, "); hql.append("bad.dateEnd as dateEndBalancer "); hql.append("from "); hql.append("IpvodIngestStage ins "); hql.append("left outer join ins.ipvodBalancer as bad "); hql.append("where "); hql.append("ins.id = " + idIngest); hql.append("order by ins.priority, ins.id asc"); Query query = getSession().createQuery(String.valueOf(hql)); query.setResultTransformer(new AliasToBeanResultTransformer(BalancerVO.class)); return query.list(); }
From source file:br.com.gvt.eng.vod.dao.IngestDAO.java
/** * Lista dados @IpvodDrmData/* w w w. j a v a2 s. c o m*/ * * @param idIngest * @return List<DrmVO> */ @SuppressWarnings("unchecked") public List<DrmVO> findDataDrm(Long idIngest) { // HQL dos dados, todos os campos devem ter o mesmo nome dos atributos // no IngestVO StringBuilder hql = new StringBuilder(); hql.append("select "); hql.append("drm.drmId as drmId, "); hql.append("drm.nameFile as nameFile, "); hql.append("drm.statusDrm as statusDrm, "); hql.append("drm.percentCompDrm as percentCompDrm, "); hql.append("drm.dateEndDrm as dateEndDrm "); hql.append("from "); hql.append("IpvodIngestStage ins "); hql.append("left outer join ins.ipvodDrm as drm "); hql.append("where "); hql.append("ins.id = " + idIngest); hql.append("order by ins.priority, ins.id asc"); Query query = getSession().createQuery(String.valueOf(hql)); query.setResultTransformer(new AliasToBeanResultTransformer(DrmVO.class)); return query.list(); }
From source file:br.com.gvt.eng.vod.dao.IngestDAO.java
/** * Lista dados @IpvodConvoyData// www .j a v a 2 s . c om * * @param idIngest * @return List<ConvoyVO> */ @SuppressWarnings("unchecked") public List<ConvoyVO> findDataConvoy(Long idIngest) { // HQL dos dados, todos os campos devem ter o mesmo nome dos atributos // no IngestVO StringBuilder hql = new StringBuilder(); hql.append("select "); hql.append("conv.convoyId as convoyId, "); hql.append("conv.nameFile as nameFile, "); hql.append("conv.statusConvoy as statusConvoy, "); hql.append("conv.percentCompConvoy as percentCompConvoy, "); hql.append("conv.dateEnd as dateEndConvoy "); hql.append("from "); hql.append("IpvodIngestStage ins "); hql.append("left outer join ins.ipvodConvoy as conv "); hql.append("where "); hql.append("ins.id = " + idIngest); hql.append("order by ins.priority, ins.id asc"); Query query = getSession().createQuery(String.valueOf(hql)); query.setResultTransformer(new AliasToBeanResultTransformer(ConvoyVO.class)); return query.list(); }
From source file:br.com.gvt.eng.vod.dao.IngestDAO.java
/** * Lista dados @IpvodCheckSumData//from ww w . j ava2 s .c o m * * @param idIngest * @return List<CheckSumVO> */ @SuppressWarnings("unchecked") public List<CheckSumVO> findDataCheckSum(Long idIngest) { // HQL dos dados, todos os campos devem ter o mesmo nome dos atributos // no IngestVO StringBuilder hql = new StringBuilder(); hql.append("select "); hql.append("check.checkSumId as checkSumId, "); hql.append("check.fileName as fileName, "); hql.append("check.checkSumSend as checkSumSend, "); hql.append("check.checkSumResult as checkSumResult, "); hql.append("check.statusFile as statusFile "); hql.append("from "); hql.append("IpvodIngestStage ins "); hql.append("left outer join ins.ipvodCheckSumData as check "); hql.append("where "); hql.append("ins.id = " + idIngest); hql.append("order by ins.priority, ins.id asc"); Query query = getSession().createQuery(String.valueOf(hql)); query.setResultTransformer(new AliasToBeanResultTransformer(CheckSumVO.class)); return query.list(); }