-->
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: Newbie: Querying A Multiple Association
PostPosted: Thu Jun 20, 2013 2:39 pm 
Newbie

Joined: Thu Jun 20, 2013 2:19 pm
Posts: 1
I have two classes (i.e. I removed the mapped attributes to the dbase columns to keep it short):

@Entity
@Table(name = "Appeal_Header")
public class AppealHeader implements Serializable {
private static final long serialVersionUID = -8402922611571578104L;

@Id
@Column(name = "Appeal_Header_Key", unique=true, nullable=false)
private long id;

@Column(name = "customer_cd", unique=true, nullable=false)
private String customer;

@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="hes_invoice_header_id", insertable=false, updatable=false, nullable=false)
private BillingHeader billingHeader;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public BillingHeader getBillingHeader() {
return billingHeader;
}

public void setBillingHeader(BillingHeader billingHeader) {
this.billingHeader = billingHeader;
}

public String getCustomer() {
return customer;
}

public void setCustomer(String customer) {
this.customer = customer;
}

}


@Entity
@Table(name = "billing_header")
public class BillingHeader implements Serializable {
private static final long serialVersionUID = 503665425710114912L;

@Id
@Column(name="hes_invoice_header_id", insertable=false, updatable=false, unique=true, nullable=false)
private long id;

@Column(name="claim_number", insertable=false, updatable=false, unique=false, nullable=false)
private String claimNumber;

@OneToMany(cascade={CascadeType.ALL})
@JoinColumn(name="hes_invoice_header_id", insertable=false, updatable=false, nullable=false)
private List<AppealHeader> appealHeader;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getClaimNumber() {
return claimNumber;
}

public void setClaimNumber(String claimNumber) {
this.claimNumber = claimNumber;
}

public List<AppealHeader> getAppealHeader() {
return appealHeader;
}

public void setAppealHeader(List<AppealHeader> appealHeader) {
this.appealHeader = appealHeader;
}
}


Now, I'm executing this criteria query:

Criteria criteria = session.createCriteria(AppealHeader.class);

if(!"".equals(form.getCustomer()))
criteria.add(Restrictions.eq("customer",form.getCustomer()));
if(!"".equals(form.getClaimNumber()))
criteria.add(Restrictions.eq("billingHeader.claimNumber",form.getClaimNumber()));

If I query by customer I get back all the appeal header records plus the associated billing headers. But if I query by customer and billingHeader.claimNumber of just billingHeader.claimNumber alone. I get this exception:

org.hibernate.QueryException: could not resolve property: billingHeader.claimNumber of: healthe.appeals.model.AppealHeader

Can anybody help me out please??

Thanks!


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.