I am trying to execute the following code and when I retrieve data, it displays the same data four times although I should get four different vaules. Please tell me what is wrong.
SessionFactory sessionfactory = new Configuration().configure().buildSessionFactory(); Session session = sessionfactory.openSession(); session.beginTransaction();
Query query = session.createQuery("select b from MstCurrency b where b.id_Entity = :identity "); query.setString("identity", "B001")
System.out.println("COUNT : "+query.list().size());
for(Iterator it=query.iterate();it.hasNext();) { MstCurrency currency = (MstCurrency)it.next(); System.out.println(currency.getCodcurrency()); System.out.println(currency.getId_Entity()); System.out.println(currency.getIslocal()); System.out.println(currency.getNamcurrency()); } session.beginTransaction().commit();
RESULT :
COUNT : 4 113 B001 N EURO 113 B001 N EURO 113 B001 N EURO 113 B001 N EURO
|