Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate 4.2.5.Final and Spring 3.2.4 - Alternatives to getHibernateTemplate().find(query, param);
    primarykey
    data
    text
    <p>We are in the process of upgrading to hibernate 4.2.5.final and Spring 3.2.4 in the process we need to remove <code>getHibernateTemplate()</code> and use <code>getSessionFactory().getCurrentSession()</code>. I was just wondering if there is an alternative for <code>getHibernateTemplate().find(query, param);</code>? for examples there are lots of lots like the following in the project:</p> <pre><code>public List&lt;T&gt; findByQuery(String query, Object... params) { return getHibernateTemplate().find(query, params); } public List&lt;T&gt; findByQuery(String query, Object param) { return getHibernateTemplate().find(query, param); } public List&lt;T&gt; findByQuery(String query) { return getHibernateTemplate().find(query); } </code></pre> <p>and the methods calling them will be something like:</p> <pre><code>public List&lt;GroupField&gt; find(Group group) { return findByQuery("from GroupField where group = ? order by id asc", group); } </code></pre> <p>I can do something like as follow:</p> <pre><code>public List&lt;T&gt; findByQuery(String hql, Object... params) { Query query = getSessionFactory().getCurrentSession().createQuery(hql); if (params !=null){ for (int i = 0; i &lt; params.length ; i++) { query.setParameter (i, params[i]); } } return query.list(); } </code></pre> <p>but then hibernate will complain about Positional parameter are considered deprecated; use named parameters or JPA-style positional parameters instead.</p> <p>Any help would be appreciate it </p> <p>Many thanks in advance</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. 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