-->
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.  [ 3 posts ] 
Author Message
 Post subject: how to map a result list to object?or how to bind a object ?
PostPosted: Wed May 23, 2007 12:14 am 
Newbie

Joined: Wed May 23, 2007 12:02 am
Posts: 6
Location: china
Hi All,

how to map a result list to object?or how to bind a object to query?
example for:

Query query=session.createQuery("select bag.name, bag.tile,bag.size from Bag bag where bag.id=:id");

List list=query.list();

how to get Bag from list?
as bag=(Bag)list.get(i);
I want not to do as

Object[] objs=(Object[])list.get(i);

can I bend a class to query as

session.createSqlQuery("").addEntityClass(Class);

if not? why hibernate not to implement it?

thank you

















Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject: it is how to bind a entity to reuslt list
PostPosted: Wed May 23, 2007 1:02 am 
Newbie

Joined: Wed May 23, 2007 12:02 am
Posts: 6
Location: china
it is how to bind a entity to reuslt list


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 1:04 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

in hibernate 3.x there is a method
Code:
session.createSQLQuery("select * from Table").addEntity(Table.class).list();


this will return a list of Table type objects


Amila

(Don't forget to rate if it helps)


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

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.