-->
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.  [ 4 posts ] 
Author Message
 Post subject: addEntity() help
PostPosted: Fri Jan 18, 2008 1:31 am 
Newbie

Joined: Tue Dec 05, 2006 3:00 am
Posts: 15
Please see below scenario

Table A
---------
col1 number,
col2 varchar2,
col3 date,
...
...
...
col10 varchar2


Query
-------

select col1,col2,col5 from A.

Question
======

Can I use addEntity() for above Query not for {select * from A}.

I need some columns only with ORM .


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 18, 2008 4:36 am 
Newbie

Joined: Wed Dec 19, 2007 7:28 am
Posts: 9
Yes You can use it.
The list() function of the org.hibernate.Query/SQLQuery to retrieve the selective columns as a list.

_________________
Sarika


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 18, 2008 5:10 am 
Newbie

Joined: Tue Dec 05, 2006 3:00 am
Posts: 15
sarikapj wrote:
Yes You can use it.
The list() function of the org.hibernate.Query/SQLQuery to retrieve the selective columns as a list.



Hi Sarika,

Thanks for your reply. Sorry this is not correct answer for my question. Please see below once.

When we call query.list() for {select col1,col2,col5 from A} then we get objects[] in a List. These all are scalar values . But I need A.java beans[POJO] instead of object[] array.

Can we can get java beans[POJO] instead of object[]s ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 20, 2008 9:57 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Quote:

When we call query.list() for {select col1,col2,col5 from A} then we get objects[] in a List. These all are scalar values . But I need A.java beans[POJO] instead of object[] array.

Can we can get java beans[POJO] instead of object[]s ?


Yes, you can if you do a native query and map the query to a sqlResultMapping-class (have a look at the JPA spec). This class should be a simple pojo and not an entity.

Carlo

=============================
if this answer helped you don't forget
to give me some credits.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.