-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Improving the Fetching of data from DB
PostPosted: Wed Oct 15, 2008 7:48 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
Hi Friends!
I am new to hibernate. now i am working in hibernate enhancement project. For this project we are using MyEclipse 5.5 and MySQL 5.0.
where i am using HQL queries to retrieve data from mysql database.
the code like as

Code:
public String[] checkSecurityCode(String code){
      String[] result = new String[8];
      BaseHibernateDAO dao=null;
      try {
      dao= new BaseHibernateDAO();
      session =dao.getSession();
      txt=session.beginTransaction();
      Iterator results =session.createQuery("from Users u where u.username='admin'").iterate();
          if(results.hasNext()) {
             Users u=(Users)results.next();
            String uid =u.getUserId().toString();
            
            MessageDigest md = MessageDigest.getInstance("MD5");
                md.update(code.getBytes());
                String encodedCode = new String(Base64.encode(md.digest()));
               
                String encodedDbSecurityCode = u.getSecurityCode();
                if(!encodedDbSecurityCode.equals(encodedCode)) {
                   result[0] = "<b>Sorry!</b> Incorrect security code.";
                }
                else if(encodedDbSecurityCode.equals(encodedCode)) {
                   result[0] = "Success";
                   result[1] = uid;
                   result[2] = u.getDashFlag();
                   result[3] = u.getUserGroup().toString();
                   result[4] = u.getUserRole();
                   long nextPasswordChange = u.getNextPasswordChange();
                   boolean changePwd = new Date().getTime() >= nextPasswordChange;
                   result[5] = Boolean.toString(changePwd);
                   result[6] = u.getHasMessage().toString();
                   result[7] = u.getLastLogin().toString();
                   new Update().setUserValidLogin(uid, session);
                }
         }
      }
      catch (Exception e) {
         System.out.println("Exception in Retrieve > checkSecurityCode: " + e.getMessage());
         result[0] = "Sorry! There was a problem while processing your request.";
      }
      finally{
         txt.commit();
         session.close();         
      }      
      return result;
   }   


But it's very slow when compared to native JDBC code.
Could anyone guide me to improve fetching performance and techniques to tuning MySQL DB for hibernate. How to write better hibernate code for insert, retrieve, update and delete operations for my project. In our project we are just converting all SQL queries to HQL queries, just all.

If u know any books and articles for hibernate tuning for MySQL 5.0 for better performance.It's very helpful to me and team. Becaz our project is real time project, going to process thousand of thousands data in a second. So plz provide me some help, it's very urgent.Thanks in advance.

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.