Package org.hibernate

Examples of org.hibernate.SessionFactory


public class UserManagerImpl extends BaseHibernateDataHandler implements IUserManager {

 
  public List<BOUser> getAllUsers() {
    SessionFactory sessionFactory = null;
    Session session = null;
    try {
      sessionFactory = HibernateSessionFactory.getInstance();
      session = sessionFactory.openSession();

      Criteria criteria = session.createCriteria(BOUser.class);
      session.flush();
     
      return criteria.list();
View Full Code Here


    }
  }

  public BOUser getUser(String userName, String password) {
    //initCustomFields();
    SessionFactory sessionFactory = null;
    Session session = null;
    BOUser user = null;
    try {
      sessionFactory = HibernateSessionFactory.getInstance();
      session = sessionFactory.openSession();

      Query query = session.createQuery("from BOUser as user where user.loginName = :username and user_password = MD5(:password)");
      query.setString("username", userName);
      query.setString("password", password);
      List<BOUser> lstUsers = query.list();
View Full Code Here

  public List<BOUser> getUsers(String strIds) {
    List<Long> ids = new ArrayList<Long>();
    for(String id : strIds.split(",")) {
      ids.add(Long.parseLong(id));
    }
    SessionFactory sessionFactory = null;
    Session session = null;
    try {
      sessionFactory = HibernateSessionFactory.getInstance();
      session = sessionFactory.openSession();

      Criteria criteria = session.createCriteria(BOUser.class);
     
      criteria.add(Restrictions.in("userID", ids));
      return criteria.list();
View Full Code Here

    Add, Update, Delete, Merge
  }

  public void performDBAction(Object objToSave, String criteria) {
    Transaction transaction = null;
    SessionFactory sessionFactory = null;
    Session session = null;

    try {
      sessionFactory = HibernateSessionFactory.getInstance();
      session = sessionFactory.openSession();
      transaction = session.beginTransaction();

      if (criteria.equalsIgnoreCase("Add") || criteria.equalsIgnoreCase("Update")) {
        session.saveOrUpdate(objToSave);
      } else if (criteria.equalsIgnoreCase("Delete")) {
View Full Code Here

  /* (non-Javadoc)
   * @see com.zycus.dotproject.impl.ICompanyManager#getAllCompanies(com.zycus.dotproject.bo.BOUser, com.zycus.dotproject.bo.BOCompany)
   */
  public List<BOCompany> getAllCompanies(BOUser user) {
    SessionFactory sessionFactory = null;
    Session session = null;
    try {
      sessionFactory = HibernateSessionFactory.getInstance();
      session = sessionFactory.openSession();

     
     
      if(user.getUserType()==UserType.Administrator)
      {
View Full Code Here

    }
  }
 
  public Object merge(Object objToSave) {

    SessionFactory sessionFactory = null;
    Session session = null;

    try {
      sessionFactory = HibernateSessionFactory.getInstance();
      session = sessionFactory.openSession();
      Object mergedObject = session.merge(objToSave);
      return mergedObject;

    } catch (Exception a_th) {
      throw new RuntimeException(a_th);
View Full Code Here

    }
  }

  public void performDBAction(Object objToSave, DBActionCriteria criteria) {

    SessionFactory sessionFactory = null;
    Session session = null;

    try {
      sessionFactory = HibernateSessionFactory.getInstance();
      session = sessionFactory.openSession();
      performDBAction(objToSave, criteria, session);

    } catch (Exception a_th) {
      throw new RuntimeException(a_th);
    } finally {
View Full Code Here

    */
   public Session create(Bean<Session> bean, CreationalContext<Session> arg0)
   {
      try
      {
         SessionFactory sf = getSessionFactory();
         Session session = sf.openSession();
         session = (Session) persistenceProvider.proxyDelegate(session);
         HibernateManagedSessionProxyHandler handler = new HibernateManagedSessionProxyHandler(session, manager, bean.getQualifiers(), persistenceProvider, manager);
         Session proxy = (Session) proxyConstructor.newInstance(handler);
         try
         {
View Full Code Here

 
  public static List<process> viewRecord(String s[]){ 
   
   
   
    SessionFactory sf=new Configuration().configure().buildSessionFactory();
    Session session=sf.openSession();
   
    Criteria c1=session.createCriteria(process.class);
    // c1.add(Restrictions.and(Restrictions.eq("id", new Integer(0)),Restrictions.like("username","vipul")));
          //      c1.addOrder(Order.desc("id"));
          //      c1.setProjection(Projections.property("username"));
          //      c1.setProjection(Projections.property("address"));
    int len=s.length;
    System.out.println(len);
   
    ProjectionList p1=Projections.projectionList();        
    for(int i=0; i<len; i++)
    {
                 p1.add(Projections.property(s[i]));
                 System.out.println(s[i]);
                
          //        p1.add(Projections.property("address"));
    }          
                 
          c1.setProjection(p1);
                   List l1 = (List) c1.list();
                 // Iterator i =l1.iterator();
                 // while(i.hasNext())
                  //{
       //                   Object o[]=(Object [])i.next();
       //                   System.out.println(o[0] + "==" + o[1]);
                         
                         
              //         String str=(String) i.next();
            //   System.out.println(str);
                  /*
                          Object o=i.next();
                          login l11=(login)o;
                          System.out.println(l11.getid());
                          System.out.println(l11.getaddress());
                          System.out.println(l11.getemail());
                          System.out.println(l11.getpassword());
                          System.out.println(l11.getphonenumber());
                          System.out.println(l11.getusername());
                  */
                  //}
                  System.out.println("save");
                 
                  session.close();
                  sf.close();

     
   
    return l1;
   
View Full Code Here

    return new OgmEntityManager( this, (HibernateEntityManagerImplementor) hibernateEmf.createEntityManager( synchronizationType, map ) );
  }

  @Override
  public SessionFactory getSessionFactory() {
    final SessionFactory sessionFactory = ( (HibernateEntityManagerFactory) hibernateEmf ).getSessionFactory();
    return new OgmSessionFactoryImpl( (SessionFactoryImplementor) sessionFactory );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.SessionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.