Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate query result is empty
    primarykey
    data
    text
    <p>I am learning hibernate and made a simple program to read a table from my sql.<br>The result list that I am getting after executing the query is having size zero even though table has 14 records in it.<br>I made the show_sql to see the sql logs and I am getting this : <br></p> <pre><code>log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. Hibernate: select insurance0_.lngInsuranceId as col_0_0_ from insurance insurance0_ </code></pre> <p>I am also attaching code for reference<br></p> <pre><code>Session session = new Configuration().configure("Hibernate.cfg.xml").buildSessionFactory().openSession(); String SQL_QUERY ="from Insurance insurance"; Query query = session.createQuery(SQL_QUERY); System.out.println("size of list is: "+query.list().size()); List resultList = query.list(); for (Iterator iterator = resultList.iterator(); iterator.hasNext();) { Insurance object = (Insurance) iterator.next(); System.out.println("insurance name is: "+object.getInsuranceName()); System.out.println("insurance amount is: "+object.getInvestementAmount()); } session.close(); </code></pre> <p>Entity class :<br></p> <pre><code>public class Insurance { private long lngInsuranceId; private String insuranceName; private int investementAmount; private Date investementDate; public long getLngInsuranceId() { return lngInsuranceId; } public void setLngInsuranceId(long lngInsuranceId) { this.lngInsuranceId = lngInsuranceId; } public String getInsuranceName() { return insuranceName; } public void setInsuranceName(String insuranceName) { this.insuranceName = insuranceName; } public int getInvestementAmount() { return investementAmount; } public void setInvestementAmount(int investementAmount) { this.investementAmount = investementAmount; } public Date getInvestementDate() { return investementDate; } public void setInvestementDate(Date investementDate) { this.investementDate = investementDate; } </code></pre> <p>}</p> <p>Please help as I am not able to zero in this issue?</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.
 

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