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: Why hibernate query database after I refresh page five time
PostPosted: Sat Sep 25, 2004 9:06 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
2.1.6



<class name="lyo.test.Child" table="child">
<id name="user_id" column="user_id" type="string">
<generator class="native"/>
</id>
<property name="user_name">
<column name="user_name" sql-type="varchar(20)"/>
</property>
..............................
</class>

<class name="lyo.test.Parent" table="parent">
<id name="user_id" column="user_id" type="string">
<generator class="native"/>
</id>
<property name="user_name">
<column name="user_name" sql-type="varchar(20)"/>
</property>
..............................
</class>




Session _session=HibernateUtil.currentSession();
Transaction t=_session.beginTransaction();
String sql="select element(p.child) from Parent p where p.user_name='"+logonName+"'";
log.info("Get sell SQL>>> "+sql);
List childList=_session.find(sql);
log.info("Get sellsize: >>"+sellhouseList.size());
return childList;


No Exceptions:

MySQL4.0.13:

The generated SQL (show_sql=true):

INFO:

Hi everyone:

I come accross a problem in Tomcat5 and Hibernate. I have two class, parent and child.In J2EE environment,I get data from
jsp like this:
Code:
UserDAO udao=DAOFactory.getUserDAOInstance();
  List childList=udao.getChildFromParentLogonname(parentname); // I want to display data in jsp
.............................................................

The getChildFromParentLogonname method is this:
Code:
Session _session=HibernateUtil.currentSession();
      Transaction t=_session.beginTransaction();
      String sql="select element(p.child) from Parent p where p.user_name='"+logonName+"'";
      log.info("Get sell SQL>>> "+sql);
      List childList=_session.find(sql);
      log.info("Get sellsize: >>"+sellhouseList.size());
                 t.commit();
      HibernateUtil.closeSession();
      return childList;


If parent logon success,the page will redirect to the page that display child list.But the first time I
enter the page ,nothing displayed. After I refresh the page 4~5 times ,the child list display.
I add proxy to child.hbm.xml,
Code:
<class name="lyo.test.Child" table="child" proxy="lyo.test.Child">
.................................................................

it works well! the first time I enter ,the data will be displayed!
And more,if I don't use proxy,the above program will don't process this code:
Code:
log.info("Get sellsize: >>"+sellhouseList.size());

But if I use the proxy,I need have to close Session in Filter. :-(
Why this happen?

_________________
You are not alone...


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.