-->
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: @SqlResultSetMappings without Entity
PostPosted: Tue Jul 20, 2010 12:33 pm 
Newbie

Joined: Thu Jul 01, 2004 9:27 am
Posts: 7
I do not know if this is a bug or whether it should work this way, but I have the following issue:

I have Entity classes which define my Business Logic.
To do stuff I have created Manager classes which are more or less the same as Stateless beans (For legacy reasons we need to use Tomcat, so no true EE stuff).

In one of the Manager classes I want to use a native query which returns scalar types.
So I created a @SqlResultSetMapping annotation for the manager and created the code to execute the native query.
However when I try to execute the code it complains that no @SqlResultSetMapping exists with the given name.
See snippet below:
Code:
@SqlResultSetMappings( {
@SqlResultSetMapping( name = "StockInfo", columns = { @ColumnResult( name = "product_id" ), @ColumnResult( name = "product_value" ), @ColumnResult( name = "product_name" ),
      @ColumnResult( name = "vendor_id" ), @ColumnResult( name = "totalminimumstock" ), @ColumnResult( name = "qtyonhand" ), } ) })
public class StockManager


I then moved the @SqlResultSetMappings to one of the @Entity annotated classes (pure randon because it has no real meaning for the Entity) and suddenly the code works.
Code:
@Entity
@SqlResultSetMappings( {
@SqlResultSetMapping( name = "ProductProposalStockInfo", columns = { @ColumnResult( name = "product_id" ), @ColumnResult( name = "product_value" ), @ColumnResult( name = "product_name" ),
      @ColumnResult( name = "vendor_id" ), @ColumnResult( name = "totalminimumstock" ), @ColumnResult( name = "totalQtyOnHand" ), } ) })
public class Address


So it seams that the @SqlResultSetMappings annotation is only detected by Hibernate when in combination with an @Entity annotation. Is this a correct conclusion?
Shouldn't the detection also look for this @SqlResultSetMapping(s) annotation separately form the @Entity annotation when parsing the class files?

Is there another way to use the @SqlResultSetMappings annotation without putting it in a unrelated @Entity class. I think this is strange because you want to keep that definition in a logical place where it is also used and currently I am unable to do that.

Thanks for your thoughts on this

_________________
www.africarevealed.com


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.