List of usage examples for org.hibernate SessionFactory getCurrentSession
Session getCurrentSession() throws HibernateException;
From source file:smile.weixin.jdquanyi.database.Database.java
public boolean FuXiuExists(String fromUserName) { boolean exist = false; SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); Session s = sf.getCurrentSession(); s.beginTransaction();/* w ww . java2s . c o m*/ // System.out.println("begintransaction"); Query q = s.createQuery("from FX_FuXiu"); List<FX_FuXiu> fx_list = q.list(); s.getTransaction().commit(); sf.close(); for (FX_FuXiu f : fx_list) { if (f.getFx_fromUserName().equals(fromUserName)) { exist = true; break; } } return exist; }
From source file:smile.weixin.jdquanyi.database.Database.java
public int GongYiSanExists(String fromUsername) { int exits = 0; SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); Session s = sf.getCurrentSession(); s.beginTransaction();/*w w w. ja va2 s .c o m*/ Query q = s.createQuery("from GYS_GongYiSan"); List<GYS_GongYiSan> gys_list = q.list(); s.getTransaction().commit(); sf.close(); for (GYS_GongYiSan gys : gys_list) { if (gys.getGYS_fromUserName().equals(fromUsername)) { exits = 1; } if (gys.getGYS_fromUserName().equals(fromUsername) && gys.getGYS_verification()) { exits = 2; } } return exits; }
From source file:smile.weixin.jdquanyi.database.Database.java
public boolean AddFuxiu(FX_FuXiu fx_user) { SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); Session s = sf.getCurrentSession(); s.beginTransaction();/*from ww w . j ava 2 s .c o m*/ s.save(fx_user); s.getTransaction().commit(); sf.close(); return true; }
From source file:smile.weixin.jdquanyi.database.Database.java
public boolean AddGongYiSan(GYS_GongYiSan gys_user) { SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); Session s = sf.getCurrentSession(); s.beginTransaction();//from www .j av a2s. co m s.save(gys_user); s.getTransaction().commit(); sf.close(); return true; }
From source file:smile.weixin.jdquanyi.database.Database.java
public boolean GongYiSanIsPure(String fromUserName) { boolean pure = true; SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); Session s = sf.getCurrentSession(); s.beginTransaction();/*from w w w .j a v a 2s.c o m*/ Query q = s.createQuery("from GYS_GongYiSan"); List<GYS_GongYiSan> gys_list = q.list(); s.getTransaction().commit(); sf.close(); for (GYS_GongYiSan gys : gys_list) { if (gys.getGYS_fromUserName().equals(fromUserName)) { pure = gys.getGYS_pure(); break; } } return pure; }
From source file:smile.weixin.jdquanyi.database.Database.java
public boolean GongYiSanIsVerified(String fromUserName) { boolean verified = false; SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); Session s = sf.getCurrentSession(); s.beginTransaction();/*w w w . j av a 2 s. c om*/ Query q = s.createQuery("from GYS_GongYiSan"); List<GYS_GongYiSan> gys_list = q.list(); s.getTransaction().commit(); sf.close(); for (GYS_GongYiSan gys : gys_list) { if (gys.getGYS_fromUserName().equals(fromUserName)) { verified = gys.getGYS_verification(); break; } } return verified; }
From source file:smile.weixin.jdquanyi.database.Database.java
public List<SW_ShiWu> GetShiWuInfs() { SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); Session s = sf.getCurrentSession(); s.beginTransaction();//w w w .ja v a2s . c o m Query q = s.createQuery("from SW_ShiWu"); List<SW_ShiWu> sw = q.list(); s.getTransaction().commit(); sf.close(); //System.out.println("Query OK!"); return sw; }
From source file:smile.weixin.jdquanyi.database.Database.java
public int getGYS_Id(String fromUserName) { int id = 0;// w ww .jav a 2s.c o m SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); Session s = sf.getCurrentSession(); s.beginTransaction(); Query q = s.createQuery("from GYS_GongYiSan"); List<GYS_GongYiSan> gys_list = q.list(); s.getTransaction().commit(); sf.close(); for (GYS_GongYiSan gys : gys_list) { if (gys.getGYS_fromUserName().equals(fromUserName)) { id = gys.getGYS_id(); break; // System.out.println(id); } } return id; }
From source file:smile.weixin.jdquanyi.database.Database.java
public List<WM_WaiMai> getWaiMai() { SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); Session s = sf.getCurrentSession(); s.beginTransaction();/*from w ww . j a v a2 s . c om*/ Query q = s.createQuery("from WM_WaiMai"); List<WM_WaiMai> wm_list = q.list(); s.close(); return wm_list; }
From source file:smile.weixin.jdquanyi.database.Database.java
public int getWC_count() { int weekcount = -1; SessionFactory sf = new AnnotationConfiguration().configure().buildSessionFactory(); Session s = sf.getCurrentSession(); s.beginTransaction();//from w w w . j a v a2s . c o m Query q = s.createQuery("from WC_WeekCount"); List<WC_WeekCount> wc_list = q.list(); sf.close(); for (WC_WeekCount wc : wc_list) { if (1 == wc.getId()) { weekcount = wc.getCount(); break; } } return weekcount; }