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


Java Query.getSingleResult方法代码示例

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


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

示例1: getUserFromEmail

import org.hibernate.Query; //导入方法依赖的package包/类
synchronized public static UserDetails getUserFromEmail(String email)
{
         UserDetails ud = null;
         int chk=0;
         sf=Logic.getSf();
         Session s = null;
         try{
                s=sf.openSession();
                s.beginTransaction();
                Query qry=s.createQuery("from UserDetails ud where ud.email_id=:eid");
                qry.setParameter("eid", email);
                ud=(UserDetails)qry.getSingleResult();
                s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                          System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
            if(chk==0)
            {
                 //ud=lst.get(0);
                 return (ud);
            }
            else
            {
                 return (new UserDetails());
            }
}
 
开发者ID:Tejas07PSK,项目名称:EBwn2_ForOpenShift,代码行数:38,代码来源:Fetch.java

示例2: getPlaceFromDesc

import org.hibernate.Query; //导入方法依赖的package包/类
synchronized public static Places getPlaceFromDesc(String desc)
{
         Places pl = null;
         int chk=0;
         sf=Logic.getSf();
         Session s = null;
         try{
                s=sf.openSession();
                s.beginTransaction();
                Query qry=s.createQuery("from Places pl where pl.pl_desc=:pldesc");
                qry.setParameter("pldesc", desc);
                pl=(Places)qry.getSingleResult();
                s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                          System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
            if(chk==0)
            {
                 return (pl);
            }
            else
            {
                 return (new Places());
            }
}
 
开发者ID:Tejas07PSK,项目名称:EBwn2_ForOpenShift,代码行数:37,代码来源:Fetch.java

示例3: getUserFromId

import org.hibernate.Query; //导入方法依赖的package包/类
synchronized public static UserDetails getUserFromId(String userid)
{
         UserDetails ud = null;
         int chk=0;
         sf=Logic.getSf();
         Session s = null;
         try{
                s=sf.openSession();
                s.beginTransaction();
                Query qry=s.createQuery("from UserDetails ud where ud.usr_id=:uid");
                qry.setParameter("uid", userid);
                ud=(UserDetails)qry.getSingleResult();
                s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                          System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
            if(chk==0)
            {
                 return (ud);
            }
            else
            {
                 return (new UserDetails());
            }
}
 
开发者ID:Tejas07PSK,项目名称:EBwn2_ForOpenShift,代码行数:37,代码来源:Fetch.java

示例4: getUserFromEmail

import org.hibernate.Query; //导入方法依赖的package包/类
synchronized public static UserDetails getUserFromEmail(String email)
{
         UserDetails ud = null;
         int chk=0;
         sf=Logic.getSf();
         Session s = null;
         try{
                s=sf.openSession();
                s.beginTransaction();
                Query qry=s.createQuery("from UserDetails ud where ud.email_id=:eid");
                qry.setParameter("eid", email);
                ud=(UserDetails)qry.getSingleResult();
                s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                         System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
            if(chk==0)
            { 
                 return (ud);
            }
            else
            {
                 return (new UserDetails());
            }
}
 
开发者ID:Tejas07PSK,项目名称:maven_EWorld_OpenShift,代码行数:37,代码来源:Fetch.java

示例5: getPlaceFromDesc

import org.hibernate.Query; //导入方法依赖的package包/类
synchronized public static Places getPlaceFromDesc(String desc)
{
         Places pl = null;
         int chk=0;
         sf=Logic.getSf();
         Session s = null;
         try{
                s=sf.openSession();
                s.beginTransaction();
                Query qry=s.createQuery("from Places pl where pl.pl_desc=:pldesc");
                qry.setParameter("pldesc", desc);
                pl=(Places)qry.getSingleResult();
                s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                         System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
            if(chk==0)
            {
                 return (pl);
            }
            else
            {
                 return (new Places());
            }
}
 
开发者ID:Tejas07PSK,项目名称:maven_EWorld_OpenShift,代码行数:37,代码来源:Fetch.java

示例6: setPlace

import org.hibernate.Query; //导入方法依赖的package包/类
synchronized private static Places setPlace(String ... vals)
{
         UserDetails ud=null;
         int chk=0;
         sf=Logic.getSf();
         Session s = null;
         try{
               s=sf.openSession();
               s.beginTransaction();
               Query qry=s.createQuery("from UserDetails ud where ud.usr_id=:uid");
               qry.setParameter("uid", vals[0]);
               ud=(UserDetails)qry.getSingleResult();
               s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                          System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
                
           if(chk==0)
           {
                   Places pl=new Places ();
                   Address addr = pl.getAddr();
                   pl.setPname(vals[1]);
                   pl.setPl_type(vals[2]);
                   pl.setPl_id(generatePLACE_ID());
                   addr.setLocality(vals[3]);
                   addr.setCity(vals[4]);
                   addr.setPincode(vals[5]);
                   addr.setState(vals[6]);
                   addr.setCountry(vals[7]);
                   pl.setAddr(addr);
                   pl.setPl_desc(vals[8]);
                   pl.setUd(ud);
                   return (pl);
           }
           else
           {
                return (null);
           }
 }
 
开发者ID:Tejas07PSK,项目名称:EBwn2_ForOpenShift,代码行数:51,代码来源:Insert.java

示例7: setUserRatings

import org.hibernate.Query; //导入方法依赖的package包/类
synchronized private static ArrayList<Object> setUserRatings(String ... vals)
{
         UserDetails ud=null;
         Places pl=null;
         int chk=0;
         sf=Logic.getSf();
         Session s = null;
         try{
                s=sf.openSession();
                s.beginTransaction();
                Query qry=s.createQuery("from UserDetails ud where ud.usr_id=:uid");
                qry.setParameter("uid", vals[0]);
                ud=(UserDetails)qry.getSingleResult();
                qry=s.createQuery("from Places p where p.pl_id=:pid");
                qry.setParameter("pid",vals[1]);
                pl=(Places)qry.getSingleResult();
                s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                          System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
                
           if(chk==0)
           {
                   UserRatings ur=new UserRatings ();
                   ur.setRat(vals[2]);
                   ur.setComm(vals[3]);
                   ur.setRat_id(generateRATE_ID());
                   ur.setPl(pl);
                   ArrayList<Object> arr=new ArrayList<Object> ();
                   arr.add(ud);
                   arr.add(ur);
                   return (arr);
           }
           else
           {
                return (null);
           }
         
}
 
开发者ID:Tejas07PSK,项目名称:EBwn2_ForOpenShift,代码行数:51,代码来源:Insert.java

示例8: setPlace

import org.hibernate.Query; //导入方法依赖的package包/类
synchronized private static Places setPlace(String ... vals)
{
         UserDetails ud=null;
         int chk=0;
         sf=Logic.getSf();
         Session s = null;
         try{
               s=sf.openSession();
               s.beginTransaction();
               Query qry=s.createQuery("from UserDetails ud where ud.usr_id=:uid");
               qry.setParameter("uid", vals[0]);
               ud=(UserDetails)qry.getSingleResult();
               s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                         System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
                
           if(chk==0)
           {
                   Places pl=new Places ();
                   Address addr = pl.getAddr();
                   pl.setPname(vals[1]);
                   pl.setPl_type(vals[2]);
                   pl.setPl_id(generatePLACE_ID());
                   addr.setLocality(vals[3]);
                   addr.setCity(vals[4]);
                   addr.setPincode(vals[5]);
                   addr.setState(vals[6]);
                   addr.setCountry(vals[7]);
                   pl.setAddr(addr);
                   pl.setPl_desc(vals[8]);
                   pl.setUd(ud);
                   return (pl);
           }
           else
           {
                return (null);
           }
 }
 
开发者ID:Tejas07PSK,项目名称:maven_EWorld_OpenShift,代码行数:51,代码来源:Insert.java

示例9: setUserRatings

import org.hibernate.Query; //导入方法依赖的package包/类
synchronized private static ArrayList<Object> setUserRatings(String ... vals)
{
         UserDetails ud=null;
         Places pl=null;
         int chk=0;
         sf=Logic.getSf();
         Session s = null;
         try{
                s=sf.openSession();
                s.beginTransaction();
                Query qry=s.createQuery("from UserDetails ud where ud.usr_id=:uid");
                qry.setParameter("uid", vals[0]);
                ud=(UserDetails)qry.getSingleResult();
                qry=s.createQuery("from Places p where p.pl_id=:pid");
                qry.setParameter("pid",vals[1]);
                pl=(Places)qry.getSingleResult();
                s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                         System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
                
           if(chk==0)
           {
                   UserRatings ur=new UserRatings ();
                   ur.setRat(vals[2]);
                   ur.setComm(vals[3]);
                   ur.setRat_id(generateRATE_ID());
                   ur.setPl(pl);
                   ArrayList<Object> arr=new ArrayList<Object> ();
                   arr.add(ud);
                   arr.add(ur);
                   return (arr);
           }
           else
           {
                return (null);
           }
         
}
 
开发者ID:Tejas07PSK,项目名称:maven_EWorld_OpenShift,代码行数:51,代码来源:Insert.java


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