-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Unable to retrieve all data from table
PostPosted: Mon Nov 12, 2012 3:18 am 
Newbie

Joined: Mon Nov 12, 2012 3:10 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.