-->
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.  [ 3 posts ] 
Author Message
 Post subject: property of a component with Criteria
PostPosted: Tue Jul 08, 2008 4:09 am 
Newbie

Joined: Tue Jul 08, 2008 3:49 am
Posts: 3
Hi,

I get this Exception, when I try to name a property of a component:

could not resolve property: trader.name of: api.models.orders.OrderRequest

----------------------------------------------------
my Mapping:

@Entity
public class OrderRequest {

@Id @GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "ORDER_ID")
private long id;

@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="traderId")
@ForeignKey(name="traderId")
private Individual trader;
...

@Entity
public class Individual {

@Id @GeneratedValue(strategy=GenerationType.AUTO)
private long individualId;

@Basic
private String name;
....

---------------------------------------------
my Criteria Query:


public void getOrderRequestByTraderPartName(Session session,
String traderPartName) {
List <OrderRequest> orderRequests= session.createCriteria(OrderRequest.class).
add(Restrictions.like("trader.name", "%"+traderPartName+"%")).list();
for (OrderRequest orderRequest : orderRequests) {
LOGGER.info(orderRequest);
}




Hibernate version: Hibernate 3.2.0.cr5, Oracle DBS


thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 6:11 am 
Newbie

Joined: Tue Jul 08, 2008 3:49 am
Posts: 3
I have changed the Query:

List <OrderRequest> orderRequests= session.createCriteria(OrderRequest.class).
createCriteria("trader").add(Restrictions.like("name", "%"+traderPartName+"%")).list();

and now it works. I do not know why, "dot notation" does not work.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 9:54 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
I'm pretty sure it was going to the wrong class looking for the name property.

Regardless, I'm happy you fixed it!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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