-->
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: Problems with Hibernate
PostPosted: Sun Aug 22, 2004 10:40 pm 
Newbie

Joined: Thu May 20, 2004 5:40 pm
Posts: 10
Location: Rio de Janeiro - Brazil
Hibernate version: 2.1.6

Mapping documents:

Code:
<hibernate-mapping>
    <class
        name="br.com.rangonline.model.caracteristica.TipoJava"
        table="TB_TIPO_JAVA"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="ID_TIPO_JAVA"
            type="java.lang.Integer"
            unsaved-value="none"
        >
            <generator class="native">
            </generator>
        </id>

        <property
            name="fullClassName"
            type="java.lang.String"
            update="true"
            insert="true"
            column="NOM_TIPO_JAVA"
            not-null="true"
        />
    </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

The create method:
Code:
   public void save(TipoJava tipoJava) throws SaveException, ValidationException {
      try {
         this.session.saveOrUpdate(tipoJava);
      } catch (Throwable e) {
         HibernateDaoExceptionHelper.salvar(TipoJava.class, e);
      }
   }


The list all method:
Code:
   public List buscarTodos() throws NotFoundException {
      try {
            List tiposJava = this.session.find("select t from TipoJava as t order by upper(t.fullClassName)");
         if (tiposJava.size() == 0) {
            return null;
         }
         return tiposJava;
         
      } catch (Throwable e) {
         return (List) HibernateDaoExceptionHelper.buscar(null, e);
      }
   }


Name and version of the database you are using: MySQL

When i first run the create method, followed by the list all method, it works
fine, persisting the object in the database and listing all the others...but
when i turn to run the list all method again, it reutrn null, and i've already
debug it, and i have a session initialized....i don't understand.

Thanks.
Alexandre.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 2:29 am 
Regular
Regular

Joined: Mon Oct 06, 2003 7:17 am
Posts: 58
Location: Switzerland
When you call the buscarTodos() method again, is it in the same session? When no, did you commit after calling the buscarTodos() method the first time?

Reto


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 10:38 am 
Newbie

Joined: Thu May 20, 2004 5:40 pm
Posts: 10
Location: Rio de Janeiro - Brazil
No it's not in the same session.....
I'm implementing Hibernate with PicoContainer, andthe commit code is not
executing, that's the problem.
Thanks.


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.