-->
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: hql select query to select composite key in hibernate
PostPosted: Tue Mar 19, 2013 7:36 am 
Newbie

Joined: Tue Mar 19, 2013 6:42 am
Posts: 1
Hi,

I am stuck with a problem in Hibernate.I want to query a composite key (OrderID) of Order_details class whose getters and setters are in OrderCompo class.

My select query is like this :
Code:
OrdrSumList=session.createQuery("select OrderID,(sum(item_value*item_uprice)) FROM Order_details  group by OrderID").list();   


I am getting the error:

Code:
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.IdentNode +-[IDENT] IdentNode: 'OrderID' 


Also i have to display the OrderID and the sum total in a jsp page using struts.I am not able to display two values in corresponding header in jsp page using iterator.

Can anybody help me to solve this issue.Please please please...

My code snippets are here:

Order_details.java


Code:
@Entity 
public class Order_details implements Serializable 

[b]private OrderCompo ordcmpo;[/b]//Compo class containing composite key 
private Order_Header ordr_hdr; 
     
private double item_uprice; 
private double order_disc; 
private double item_value; 
 
private Item_Master item; 
private UOM_Master uom; 
 
 
@EmbeddedId 
@AttributeOverrides({ 
@AttributeOverride(name="OrderID" ,column= @Column(name="OrderID" ,nullable=false)), 
@AttributeOverride(name="Ord_line_no" ,column= @Column(name="Ord_line_no",nullable=false)) }) 
 
public OrderCompo getOrdcmpo() { 
    return ordcmpo; 

public void setOrdcmpo(OrderCompo ordcmpo) { 
    this.ordcmpo = ordcmpo; 



OrderCompo.java Compo class containing composite key


Code:
@Embeddable 
public class OrderCompo implements Serializable 

private int OrderID; 
private int Ord_line_no; 
 
@Column( nullable = false) 
public int getOrderID() { 
    return OrderID; 

public void setOrderID(int orderID) { 
    OrderID = orderID; 

 
 
@Column( nullable = false) 
public int getOrd_line_no() { 
    return Ord_line_no; 

public void setOrd_line_no(int ord_line_no) { 
    Ord_line_no = ord_line_no; 


jsp page

Code:
<s:div cssClass="rc_trdtttl" style="width:100px;">Order ID</s:div> 
  <s:div cssClass="rc_trdtttl" style="width:100px;">Total Amount</s:div> 
 
<s:iterator value="orderList"> 
<s:div cssClass="rc_trdt" style="width:100px;"><s:property value="" /></s:div> 
<s:div cssClass="rc_trdt" style="width:100px;"><s:property value="" /></s:div> 
</s:iterator> 



Please consider my request :( .Looking forward for your response...
Thanks in advance.......


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.