当前位置: 首页>>代码示例>>Java>>正文


Java Session.createQuery方法代码示例

本文整理汇总了Java中net.sf.hibernate.Session.createQuery方法的典型用法代码示例。如果您正苦于以下问题:Java Session.createQuery方法的具体用法?Java Session.createQuery怎么用?Java Session.createQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.hibernate.Session的用法示例。


在下文中一共展示了Session.createQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStatsFromDB

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * Returns list of PersistentObject corresponding the type of
 * the statistics.
 *
 * @param session
 * @param buildID
 * @param fromDate
 * @return
 * @throws HibernateException
 */
protected List getStatsFromDB(final Session session, final int buildID, final Date fromDate,
                              final Date toDate) throws HibernateException {

  final Query q = session.createQuery("select ms from MonthlyTestStats ms " +
          " where ms.activeBuildID = ? " +
          "   and ms.testCode = ? " +
          "   and ms.sampleTime >= ? " +
          "   and ms.sampleTime <= ?");
  q.setCacheable(true);
  q.setInteger(0, buildID);
  q.setByte(1, getTestCode());
  q.setDate(2, fromDate);
  q.setDate(3, toDate);
  return q.list();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:YearlyPersistentTestStatsRetriever.java

示例2: getStatsFromDB

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * Returns list of PersistentObject corresponding the type of
 * the statistics.
 *
 * @param session
 * @param buildID
 * @param fromDate
 * @return
 * @throws HibernateException
 */
protected List getStatsFromDB(final Session session, final int buildID, final Date fromDate,
                              final Date toDate) throws HibernateException {

  final Query q = session.createQuery("select hts from HourlyTestStats hts " +
          " where hts.activeBuildID = ? " +
          "   and hts.testCode = ? " +
          "   and hts.sampleTime >= ? " +
          "   and hts.sampleTime <= ?");
  q.setCacheable(true);
  q.setInteger(0, buildID);
  q.setByte(1, getTestCode());
  q.setDate(2, fromDate);
  q.setDate(3, toDate);
  return q.list();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:HourlyPersistentTestStatsRetriever.java

示例3: getStatsFromDB

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * Returns list of PersistentObject corresponding the type of
 * the statistics.
 *
 * @param session
 * @param buildID
 * @param fromDate
 * @return
 * @throws HibernateException
 */
protected List getStatsFromDB(final Session session, final int buildID, final Date fromDate,
                              final Date toDate) throws HibernateException {

  final Query q = session.createQuery("select mts from MonthlyTestStats mts " +
          " where mts.activeBuildID = ? " +
          "   and mts.testCode = ? " +
          "   and mts.sampleTime >= ? " +
          "   and mts.sampleTime <= ?");
  q.setCacheable(true);
  q.setInteger(0, buildID);
  q.setByte(1, getTestCode());
  q.setDate(2, fromDate);
  q.setDate(3, toDate);
  return q.list();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:MonthlyPersistentTestStatsRetriever.java

示例4: getStatsFromDB

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * Returns list of PersistentObject corresponding the type of
 * the statistics.
 *
 * @param session
 * @param buildID
 * @param fromDate
 * @return
 * @throws HibernateException
 */
protected List getStatsFromDB(final Session session, final int buildID, final Date fromDate,
                              final Date toDate) throws HibernateException {

  final Query q = session.createQuery("select dts from DailyTestStats dts " +
          " where dts.activeBuildID = ? " +
          "   and dts.testCode = ? " +
          "   and dts.sampleTime >= ? " +
          "   and dts.sampleTime <= ?");
  q.setCacheable(true);
  q.setInteger(0, buildID);
  q.setByte(1, getTestCode());
  q.setDate(2, fromDate);
  q.setDate(3, toDate);
  return q.list();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:DailyPersistentTestStatsRetriever.java

示例5: lenguajePorDefecto

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * Obtiene el codigo ISO del lenguaje por defecto.
 * @ejb.interface-method
 * @ejb.permission unchecked="true"
 */
public String lenguajePorDefecto() {
    Session session = getSession();
    try {
        Query query = session.createQuery("select idi.lang from Idioma as idi where idi.orden = 0");
        query.setCacheable(true);
        List results = query.list();

        if (results.isEmpty()) {
            return null;
        } else {
            return (String) results.get(0);
        }
    } catch (HibernateException he) {
        throw new EJBException(he);
    } finally {
        close(session);
    }
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:24,代码来源:IdiomaFacadeEJB.java

示例6: existeUsuarioByForm

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * Existen usuarios relacionados con el formulario
 * @ejb.interface-method
 * @ejb.permission role-name="${role.operador}"
 * @ejb.permission role-name="${role.admin}"
 */
public boolean existeUsuarioByForm(String usuario, Long formulario){
	Session session = getSession();
    try {
    	Query query = session.createQuery("select count(g.id.codiUsuario) from RolUsuarioFormulario g where g.id.codiUsuario=? and g.id.codiForm=? ");
        query.setString(0,usuario);
        query.setLong(1,formulario);
    	query.setCacheable(true);
        List valores =  query.list();
        Integer valor = (Integer) valores.get(0);
        if(valor == 0)
        	return false;
        else
        	return true;
    } catch (HibernateException he) {
        throw new EJBException(he);
    } finally {
        close(session);
    }
	
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:27,代码来源:GruposFacadeEJB.java

示例7: listarPermisos

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * @ejb.interface-method
 * @ejb.permission role-name="${role.admin}"
 */
public List listarPermisos()
{
	Session session = getSession();
	try
	{
		Query query = session.createQuery( "FROM Permiso p");
		query.setCacheable( true );
		return query.list();
	}
 catch (HibernateException he) 
 {
     throw new EJBException(he);
 } 
 finally 
 {
     close(session);
 }
	
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:24,代码来源:PermisoFacadeEJB.java

示例8: existeUsuarioByGruposTramite

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * Existe usuario en el grupo relacionado con el tramite
 * @ejb.interface-method
 * @ejb.permission role-name="${role.operador}"
 * @ejb.permission role-name="${role.admin}"
 */
public boolean existeUsuarioByGruposTramite(String usuario, Long tramite){
	Session session = getSession();
    try {
    	Query query = session.createQuery("select count(gu.id.usuario) from RolGrupoTramite gt, GrupoUsuario gu where gu.id.usuario=? " +
    			"and gt.id.codiTra = ? and gt.id.codiGrup = gu.id.codiGrup" );
        query.setString(0,usuario);
        query.setLong(1,tramite);
        query.setCacheable(true);
        List valores =  query.list();
        Integer valor = (Integer) valores.get(0);
        if(valor == 0)
        	return false;
        else
        	return true;
    } catch (HibernateException he) {
        throw new EJBException(he);
    } finally {
        close(session);
    }
	
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:28,代码来源:GruposFacadeEJB.java

示例9: busquedaPaginada

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * Realiza b�squeda paginada del log
 * 
    * @ejb.interface-method
    * @ejb.permission role-name="${role.admin}" 
    * @ejb.permission role-name="${role.operador}"
    */
public Page busquedaPaginada(int pagina, int longitudPagina )
{
	Session session = getSession();
       try 
       {
       	Query query = 
       		session.createQuery( "FROM LogOperacion o ORDER BY o.fecha DESC, o.codigo DESC" );
       	Query queryCount = 
       		session.createQuery( "SELECT COUNT(*) FROM LogOperacion" );
           Page page = new Page( query, pagina, longitudPagina, queryCount );
           return page;
       }
       catch( HibernateException he )
       {
       	throw new EJBException( he );
       }
       catch( Exception exc )
       {
       	throw new EJBException( exc );
       }
       finally
       {
       	close( session );
       }
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:33,代码来源:LogOperacionFacadeEJB.java

示例10: documentoEnCustodia

import net.sf.hibernate.Session; //导入方法依赖的package包/类
private boolean documentoEnCustodia(Session session,Documento documento) throws Exception{
  	Query query = session.createQuery("FROM VersionCustodia AS version WHERE version.documento.codigo = :codigoDocumento");
query.setParameter("codigoDocumento", documento.getCodigo());
List custodiasDocumento = query.list();
if(custodiasDocumento != null && custodiasDocumento.size() > 0){
	//las marcamos para borrar.
	for(int i=0;i<custodiasDocumento.size();i++){
		VersionCustodia cust = (VersionCustodia)custodiasDocumento.get(i);
		if("N".equals(cust.getBorrar()+"")){
			cust.setBorrar('S');
			cust.setFecha(new Date());
			session.update(cust);
		}
	}
	return true;
}
return false;

  }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:20,代码来源:RdsFacadeEJB.java

示例11: existeUsuarioByGruposForm

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * Existe usuario en el grupo relacionado con el formulario
 * @ejb.interface-method
 * @ejb.permission role-name="${role.operador}"
 * @ejb.permission role-name="${role.admin}"
 */
public boolean existeUsuarioByGruposForm(String usuario, Long formulario){
	Session session = getSession();
    try {
    	Query query = session.createQuery("select count(gu.id.usuario) from RolGrupoFormulario gf, GrupoUsuario gu where gu.id.usuario=? " +
    			"and gf.id.codiForm =? and gf.id.codiGrup = gu.id.codiGrup" );
        query.setString(0,usuario);
        query.setLong(1,formulario);
        query.setCacheable(true);
        List valores =  query.list();
        Integer valor = (Integer) valores.get(0);
        if(valor == 0)
        	return false;
        else
        	return true;
    } catch (HibernateException he) {
        throw new EJBException(he);
    } finally {
        close(session);
    }
	
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:28,代码来源:GruposFacadeEJB.java

示例12: obtenerMensajeTramite

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * @ejb.interface-method
 * @ejb.permission role-name="${role.operador}"
 */
public MensajeTramite obtenerMensajeTramite(String idTramite,int idVersion,String idMensajeTramite){
    Session session = getSession();
    try {        	        	
    	Query query = session.createQuery("select m FROM MensajeTramite AS d join m.tramiteVersion as v join v.tramite as t where m.identificador = :mensaje and v.version = :version and t.identificador = :tramite");
    	query.setParameter("mensaje", idMensajeTramite);
        query.setParameter("version", new Integer(idVersion));
        query.setParameter("tramite", idTramite);            
        query.setCacheable(true);
        List result = query.list();

        if (result.isEmpty()) {
            return null;
        }

        MensajeTramite mensaje = (MensajeTramite) result.get(0);            
    	return mensaje;

    } catch (HibernateException he) {
        throw new EJBException(he);
    } finally {
        close(session);
    }
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:28,代码来源:MensajeTramiteFacadeEJB.java

示例13: obtenerPantalla

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * @ejb.interface-method
 * @ejb.permission unchecked="true"
 */
public Pantalla obtenerPantalla(String modeloFormulario,int versionFormulario,String nombrePantalla) {
    Session session = getSession();
    try {
    	Query query = session.createQuery("SELECT p FROM Formulario f, Pantalla AS p WHERE f.modelo =:modelo and f.version = :version and p.formulario = f and p.nombre = :nombre");
    	query.setParameter("modelo",modeloFormulario);
    	query.setParameter("version",new Integer(versionFormulario));
    	query.setParameter("nombre",nombrePantalla);        	
    	Pantalla pantalla = (Pantalla)  query.uniqueResult();
    	Hibernate.initialize(pantalla.getComponentes());
    	return pantalla;
    } catch (HibernateException he) {
        throw new EJBException(he);
    } finally {
        close(session);
    }
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:21,代码来源:PantallaFacadeEJB.java

示例14: puedoBorrarVersion

import net.sf.hibernate.Session; //导入方法依赖的package包/类
/**
 * @ejb.interface-method
 * @ejb.permission role-name="${role.admin}"
 * @ejb.permission role-name="${role.operador}"
 */
public boolean puedoBorrarVersion(Long id) {
	
	Session session = getSession();    	    	    	
    try {        	        	
    	/*
    	// Comprueba si hay plantillas
    	Version version = (Version) session.load(Version.class, id);
    	if (version.getPlantillas() != null && version.getPlantillas().size() > 0) return false;
    	*/
    	
    	// Comprueba si hay documentos que utilizan la version        	
    	Query query = session.createQuery("SELECT COUNT(*) FROM Documento AS d WHERE d.version.codigo = :id");            
        query.setParameter("id", id);
        if (Long.parseLong(query.uniqueResult().toString()) > 0) return false;            
                    
        // Puede borrarse
        return true;
        
    } catch (Exception he) {
        throw new EJBException(he);
    } finally {        	        
        close(session);
    }                
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:30,代码来源:VersionFacadeEJB.java

示例15: quedanDocumentosPendientesFirma

import net.sf.hibernate.Session; //导入方法依赖的package包/类
private boolean quedanDocumentosPendientesFirma(TramitePersistente tramite)
{	
	Session session = getSession();
	try
	{			
		Query query = session.createQuery( "SELECT d FROM DocumentoPersistente d where d.delegacionEstado = :pendienteFirmar  and  d.tramitePersistente.estadoDelegacion = :estadoDelegacionTramite and d.tramitePersistente.codigo = :idTramite"  );
		query.setParameter( "pendienteFirmar", DocumentoPersistentePAD.ESTADO_PENDIENTE_DELEGACION_FIRMA );
		query.setParameter( "estadoDelegacionTramite", TramitePersistentePAD.ESTADO_PENDIENTE_DELEGACION_FIRMA );
		query.setParameter( "idTramite", tramite.getCodigo() );
		query.setCacheable( true );
		List docs = query.list();
		if(docs != null && docs.size() > 0){
			return true;
		}else{
			return false;	
		}
	} 
	catch (Exception he) 
	{	        
		throw new EJBException(he);
    } 
	finally 
	{
        close(session);
    }
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:27,代码来源:BandejaFirmaEJB.java


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