Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Greetings... I think you are making it more complicated than it is. :)</p> <p>If you are using Spring and Hibernate (which you are), you don't really need to create your own HibernateUtils to manage the session. HibernateUtils is almost required if you don't use Spring, or else it seems redundant. It is tedious, it is one extra code you need to maintain, and you probably are not going to get it right. Your HibernateUtils doesn't seem to be implemented correctly, by the way.</p> <p>Here's how I would do it:-</p> <ol> <li><p>You need to create a sessionFactory bean:-</p> <pre><code>&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource"/&gt; &lt;property name="mappingResources"&gt; &lt;list&gt; &lt;value&gt;// .. hbm files, omitted for brevity&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="hibernateProperties"&gt; // .. dialect, etc... omitted for brevity &lt;/property&gt; &lt;/bean&gt; </code></pre></li> <li><p>Wire this sessionFactory into your DAO (, and you need a setter in your DAO too):-</p> <pre><code>&lt;bean id="messageDao" class="com.project.core.dao.hibernate.MessageDAOImpl"&gt; &lt;property name="sessionFactory" ref="sessionFactory"/&gt; &lt;/bean&gt; </code></pre></li> <li><p>To acquire the connection in your dao, just do sessionFactory.getCurrentSession(). That's it.</p></li> </ol> <p>You do the same thing by wiring the sessionFactory into your testcase.</p> <p>Here's some reference if you wish to know how to integrate Spring with Hibernate: <a href="http://static.springsource.org/spring/docs/2.5.x/reference/orm.html" rel="nofollow noreferrer">http://static.springsource.org/spring/docs/2.5.x/reference/orm.html</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload