List of usage examples for org.hibernate Criteria createAlias
public Criteria createAlias(String associationPath, String alias) throws HibernateException;
From source file:analysers.MarketValueAnalyser.java
License:Open Source License
public List<Double> createMarginalDistribution(double lower, double upper, int days, MarketValueAnalyser.Analyse period, boolean good_rep, PrintWriter writer) { HibernateSupport.beginTransaction(); Criteria c2 = HibernateSupport.getCurrentSession().createCriteria(News.class); c2.createAlias("news_details", "detail"); c2.add(Restrictions.ge("detail.total_polarity", lower)); c2.add(Restrictions.lt("detail.total_polarity", upper)); if (good_rep) { c2.createAlias("companies", "company"); c2.add(News.getNewsOfCompaniesWithGoodReputation()); }//from ww w . j a v a 2s .c o m List<News> news_list = c2.list(); HibernateSupport.commitTransaction(); System.out.println("list.size() = " + news_list.size()); PolynomialSplineFunction psf; Date publish_date; Calendar from = Calendar.getInstance(); Calendar to = Calendar.getInstance(); double[] share_price_dev; int counter = 0; News single_news; List<Company> companies; List<Double> price_devs_period = new ArrayList<Double>(); Pair<Calendar, Calendar> from_to; while (news_list.size() > 0) { single_news = news_list.get(0); news_list.remove(0); companies = single_news.getCompaniesNew(); publish_date = single_news.getDate(); //from.setTime(publish_date); //to.setTime(publish_date); from_to = MyDateUtils.getFromToCalendars(period, publish_date, days); from = from_to.getValue0(); to = from_to.getValue1(); to.set(Calendar.DAY_OF_YEAR, to.get(Calendar.DAY_OF_YEAR) + days); for (Company company : single_news.getCompaniesNew()) { //System.out.println("publish_date = " + publish_date); //System.out.println("ISIN = " + company.getIsin()); if ((psf = this.getMarketValueSplineFromTo(company, from, to)) != null) { share_price_dev = this.getSharePriceDevelopement(psf, from, to); //System.out.println(++counter); //System.out.println(share_price_dev[days - 1]); price_devs_period.add(share_price_dev[days - 1]); //day - 1 writer.println(single_news.getNewsDetails().get(0).getTotalPolarity() + ", " + share_price_dev[days - 1]); } } } /*Collections.sort(price_devs_period); List<Double> data_set = this.createDataSet(price_devs_period, -10.0f, 10.0f, 42); System.out.println(data_set); return data_set;*/ return null; }
From source file:analysers.MarketValueAnalyser.java
License:Open Source License
public static void main(String[] args) throws ParseException { HibernateSupport.beginTransaction(); Criteria cr = HibernateSupport.getCurrentSession().createCriteria(News.class); cr.createAlias("news_details", "details"); cr.add(Restrictions.ge("details.total_objectivity", 0.5)); cr.add(Restrictions.le("details.total_objectivity", 1.0)); cr.setProjection(Projections.rowCount()); long size = (long) cr.uniqueResult(); HibernateSupport.commitTransaction(); System.out.println("size = " + size); MarketValueAnalyser mva = new MarketValueAnalyser(); //mva.createDistributionTable(40, 1, MarketValueAnalyser.Analyse.AFTER, false); mva.createDistributionTable(40, 3, MarketValueAnalyser.Analyse.AFTER, false); mva.createDistributionTable(40, 5, MarketValueAnalyser.Analyse.AFTER, false); mva.createDistributionTable(40, 7, MarketValueAnalyser.Analyse.AFTER, false); mva.createDistributionTable(40, 1, MarketValueAnalyser.Analyse.BEFORE, false); mva.createDistributionTable(40, 3, MarketValueAnalyser.Analyse.BEFORE, false); mva.createDistributionTable(40, 5, MarketValueAnalyser.Analyse.BEFORE, false); mva.createDistributionTable(40, 7, MarketValueAnalyser.Analyse.BEFORE, false); }
From source file:at.ac.tuwien.ifs.tita.dao.GenericHibernateDao.java
License:Apache License
/** * Search by use of the specified search criterions, order by specified * order criterions.//from w w w. j a v a 2 s . com * * @param criterions - search criterions * @param orders - order criterions * @param aliases list of aliasnames * @return List of result records */ @SuppressWarnings("unchecked") protected List<T> findByCriteriaOrdered(Criterion criterions[], Order orders[], String aliases[]) { Criteria crit = getSession().createCriteria(this.persistenceClass); if (aliases != null) { for (String alias : aliases) { crit.createAlias(alias, alias); } } for (int i = 0; i < criterions.length; i++) { crit.add(criterions[i]); } for (int j = 0; j < orders.length; j++) { crit.addOrder(orders[j]); } crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); return crit.list(); }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
private Criteria buildArkModuleFunctionCriteria(ArkModuleFunction arkModuleFunctionCriteria) { Criteria criteria = getSession().createCriteria(ArkModuleFunction.class); if (arkModuleFunctionCriteria.getArkModule() != null && arkModuleFunctionCriteria.getArkModule().getId() != null) { criteria.add(Restrictions.eq("arkModule", arkModuleFunctionCriteria.getArkModule())); }//from w w w. j av a 2s .c o m criteria.createAlias("arkModule", "module"); criteria.addOrder(Order.asc("module.name")); criteria.addOrder(Order.asc("functionSequence")); return criteria; }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public List<ArkFunction> getArkFunctionListByArkModule(ArkModule arkModule) { Criteria criteria = getSession().createCriteria(ArkModuleFunction.class); if (arkModule.getId() != null) { criteria.add(Restrictions.eq("arkModule", arkModule)); }// ww w. j a v a 2s. co m criteria.createAlias("arkModule", "module"); criteria.addOrder(Order.asc("module.name")); criteria.addOrder(Order.asc("functionSequence")); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("arkFunction"), "arkFunction"); criteria.setProjection(projectionList); return criteria.list(); }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public List<ArkModule> getArkModuleListByArkRole(ArkRole arkRole) { Criteria criteria = getSession().createCriteria(ArkModuleRole.class); if (arkRole != null) { criteria.add(Restrictions.eq("arkRole", arkRole)); }/* w ww. j av a2 s.c om*/ criteria.createAlias("arkModule", "module"); criteria.addOrder(Order.asc("module.name")); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("arkModule"), "arkModule"); criteria.setProjection(projectionList); return criteria.list(); }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
private List<ArkModuleRole> getArkModuleRoleByArkModule(ArkModule arkModule) { Criteria criteria = getSession().createCriteria(ArkModuleRole.class); if (arkModule.getId() != null) { criteria.add(Restrictions.eq("arkModule", arkModule)); }//w ww .j a va 2s . c o m criteria.createAlias("arkModule", "module"); criteria.addOrder(Order.asc("module.name")); return criteria.list(); }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
public List<ArkRole> getArkRoleListByArkModule(ArkModule arkModule) { Criteria criteria = getSession().createCriteria(ArkModuleRole.class); if (arkModule.getId() != null) { criteria.add(Restrictions.eq("arkModule", arkModule)); }/*from ww w. j a va 2 s. c om*/ // Restrict searching/selecting of Super Administrator criteria.add(Restrictions.ne("arkModule", getArkRoleByName(au.org.theark.core.security.RoleConstants.ARK_ROLE_SUPER_ADMINISTATOR))); criteria.createAlias("arkRole", "role"); criteria.addOrder(Order.asc("role.name")); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("arkRole"), "arkRole"); criteria.setProjection(projectionList); return criteria.list(); }
From source file:au.org.theark.admin.model.dao.AdminDao.java
License:Open Source License
private Criteria buildArkModuleRoleCriteria(ArkModuleRole arkModuleRoleCriteria) { Criteria criteria = getSession().createCriteria(ArkModuleRole.class); if (arkModuleRoleCriteria.getArkModule() != null && arkModuleRoleCriteria.getArkModule().getId() != null) { criteria.add(Restrictions.eq("arkModule", arkModuleRoleCriteria.getArkModule())); }/*from w w w. j ava 2s . co m*/ if (arkModuleRoleCriteria.getArkRole() != null && arkModuleRoleCriteria.getArkRole().getId() != null) { criteria.add(Restrictions.eq("arkRole", arkModuleRoleCriteria.getArkRole())); } criteria.createAlias("arkModule", "module"); criteria.addOrder(Order.asc("module.name")); return criteria; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
public String getUserRoleForStudy(String ldapUserName, Study study) throws EntityNotFoundException { String roleName = ""; ArkUser arkUser = getArkUser(ldapUserName); StatelessSession session = getStatelessSession(); Criteria criteria = session.createCriteria(ArkUserRole.class);// getSession().createCriteria(ArkUserRole.class); criteria.createAlias("arkUser", "auserObject"); criteria.add(Restrictions.eq("arkUser", arkUser)); criteria.add(Restrictions.eq("auserObject.study", study)); criteria.setMaxResults(1);//from w w w . j ava2 s .c om ArkUserRole arkUserRole = (ArkUserRole) criteria.uniqueResult(); if (arkUserRole != null) { roleName = arkUserRole.getArkRole().getName(); } session.close(); return roleName; }