-->
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: Named Query on a ManyToOne mapped table
PostPosted: Thu Mar 27, 2008 1:59 pm 
Newbie

Joined: Thu Jan 04, 2007 6:51 pm
Posts: 6
Hi,
I am getting error while doing a findAll query on a table(Message - in my case) that has a foreign-key relationship with another table (Department). When I execute findall, it is mapping a String instead of Department object.
How I have to define the NamedQuery in this case?

Code:
@NamedQueries({
   @NamedQuery(
         name="findMessagesById",
         query="select message " +
               "FROM Message message " +
               "where message.consumer.id =  :messageId"
      )   
})
@SqlResultSetMappings({
   @SqlResultSetMapping(name="findMessagesById",
       entities={@EntityResult(entityClass=com.pcg.mbadmin.domain.Message.class)}
   ),
   @SqlResultSetMapping(name="findMessageById",
      entities={@EntityResult(entityClass=Message.class)}   
   )
})


//Member declaration

@ManyToOne (fetch=FetchType.EAGER)
@JoinColumn(name = "CONSUMER_ID", nullable = false, referencedColumnName="DEPARTMENT_ID")
private Department consumer;


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.