Results 1 to 3 of 3

Thread: Hibernate

  1. #1
    Alan is offline Member
    Join Date
    May 2007
    Posts
    39
    Rep Power
    0

    Default Hibernate

    I have the follow problem with hibernate when I want to get data from db.

    the methods are :

    public static List getModulos(String idProject,Long[] modulosID){
    Session session = SEPhibernate.getSessionFactory().getCurrentSession ();
    session.beginTransaction();
    ModulosDAO dao = new ModulosDAO(session);
    List modulos=null;
    try {
    modulos = dao.getModulos(idProject,modulosID);
    }
    catch (Exception ex) {
    ex.printStackTrace();
    }
    session.close();
    return modulos;
    }

    public List getModulos(String project,Long[] modulosID) throws HibernateException {

    Query query = session.createQuery("select M.name FROM Model.Module M where M.project.id="+project+" and M.id in (:modulosID) order by M.name")
    .setParameterList("modulosID",modulosID);
    return query.list();
    }

    it works ok, but when I reuse the methods with other values, it doesn´t get me anything

    what can I do?
    Last edited by Alan; 06-01-2007 at 02:37 AM.

  2. #2
    goldhouse is offline Senior Member
    Join Date
    Mar 2007
    Posts
    134
    Rep Power
    0

    Default

    Is your secondary level cache enabled ? Disable and try

  3. #3
    Freddie is offline Member
    Join Date
    May 2007
    Posts
    41
    Rep Power
    0

    Default

    First, use parameters for all the parameters,don't join the project there in the query, do like list (only that you use setParameter instead of etParameterList). Anyway it isn't your problem.
    Also you shoud handle the transaction, notice that your open it but you never close it
    read this:
    HIBERNATE - Relational Persistence for Idiomatic Java
    regards
    Last edited by Freddie; 06-01-2007 at 03:33 PM.

Similar Threads

  1. Hibernate, help me
    By Nick15 in forum JDBC
    Replies: 2
    Last Post: 06-05-2008, 04:39 PM
  2. Hibernate sql query
    By taicode in forum JDBC
    Replies: 0
    Last Post: 03-25-2008, 05:17 PM
  3. question about hibernate
    By bbq in forum JDBC
    Replies: 1
    Last Post: 07-09-2007, 05:04 AM
  4. Replies: 2
    Last Post: 06-30-2007, 04:01 PM
  5. Hibernate
    By Shuru in forum JDBC
    Replies: 2
    Last Post: 05-09-2007, 06:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •