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?