-->
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.  [ 3 posts ] 
Author Message
 Post subject: Improvement of request Function
PostPosted: Wed Aug 11, 2010 10:43 am 
Newbie

Joined: Wed Aug 11, 2010 10:35 am
Posts: 2
Hello,

I would like to know if there is a way to improve performance of this request

Code:
    public static boolean existModule(String _name){
        sessionFactory = HibernateFactory.getSessionFactory();
        session = sessionFactory.getCurrentSession();
        transaction = session.beginTransaction();
        Query query = session.createQuery("select module.name from Module module where module.name = '" + _name + "'");
        boolean test = query.iterate().hasNext();
        return test;
    }



like for exemple, if i have understood this request instantiate an object. It is possible to don't instanciate this object and have the same result.

Best regards,

Florent.

PS: Sorry for my english, i'm french.


Top
 Profile  
 
 Post subject: Re: Improvement of request Function
PostPosted: Thu Aug 12, 2010 4:14 am 
Newbie

Joined: Wed Aug 11, 2010 10:35 am
Posts: 2
Anybody can help me ???


Top
 Profile  
 
 Post subject: Re: Improvement of request Function
PostPosted: Thu Aug 12, 2010 5:14 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
hi delidor,

public static boolean existModule(String _name){
sessionFactory = HibernateFactory.getSessionFactory();
session = sessionFactory.getCurrentSession();
transaction = session.beginTransaction();
return session.createQuery("select count(module.name) from Module module where module.name = '" + _name + "'").uniqueResult() > 0 ? true :false;
}

try this modified query!

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


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

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.