Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with Hibernate session.createQuery(from TableProcess).list(); does not work
    primarykey
    data
    text
    <p>I've been working with Netbeans and MySQL lately to create a Spring+Hibernate application, but I've been facing some issues in my block of code:</p> <pre><code>public List listSystemProcess() { List procesosSistema = null; String hbQuery = "from TableProcess"; try { Session hbSesion = HibernatePersistenceHandler.getSessionFactory().openSession(); Transaction tx = hbSesion.beginTransaction(); Query query = hbSesion.createQuery(hbQuery); procesosSistema = query.list(); tx.commit(); hbSesion.close(); } catch (Exception e) { e.printStackTrace(); } return procesosSistema; } </code></pre> <p>This does not works at all, I get something related to SQL syntax exception, telling me there's a syntax error near "select id2_1,uj8_,5sd_11 from tb_2_1..."</p> <p>If I create a SQLQuery instead of an HQL one, it works perfectly, but I do not find useful to do this since I should be doing this for each single process, and that's tedious and it's almost the same than use JDBC.</p> <p>This works:</p> <pre><code>String hbQuery = "select p.id,p.nombre,p.descripcion,p.frecuencia_uso,t.nombre " + "from tb_proceso_sistema p inner join tb_tipo_proceso t " + "on p.tb_tipo_proceso_id = t.id"; Query query = hbSesion.createSQLQuery(hbQuery); </code></pre> <p>But when I do this, as well, my jsp changes a bit:</p> <pre><code>&lt;c:forEach items="${procesosSistema}" var="proceso"&gt; &lt;tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';"&gt; &lt;td&gt;&lt;c:out value="${proceso[0]}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${proceso[1]}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${proceso[2]}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${proceso[3]}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${proceso[4]}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/c:forEach&gt; </code></pre> <p>instead of:</p> <pre><code>&lt;c:forEach items="${procesosSistema}" var="proceso"&gt; &lt;tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';"&gt; &lt;td&gt;&lt;c:out value="${proceso.id}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${proceso.nombre}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;c:out value="${proceso.descripcion}"/&gt;&lt;/td&gt; ... &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/c:forEach&gt; </code></pre> <p>When I set in properties "show_sql", it shows a strange query as shown above, something like:</p> <pre><code>"select id2_1,uj8_,5sd_11 from SGDP-mysql123.tb_2_1.... tb0" </code></pre> <p>If somebody could help me please, I would be really grateful.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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