-->
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: Using Criteria.createAlias() with a 3-level nested property.
PostPosted: Sun Apr 05, 2009 11:21 pm 
Newbie

Joined: Thu Jul 17, 2008 1:24 pm
Posts: 9
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.3.0

Name and version of the database you are using: Oracle 10g

Mapped classes

Code:
@MappedSuperclass
public class Model implements Serializable {
   private Long id;

   @Id
   @GeneratedValue
   public Long getId() {
      return id;
   }   
}

@Entity
public class Order extends Model {
   private Location destination;

   @ManyToOne
   public Location getDestination() {
      return destination;
   }
}

@Entity
public class Location extends Model {
   
   private Station station;

   @ManyToOne
   public Station getStation() {
      return station;
   }
}

@Entity
public class Station extends Model {
   private String name;
   private String number;
   
   public String getName() {
      return name;
   }
   
   public String getNumber() {
      return number;
   }
}


I am using the Criteria api to generate dynamic queries to return orders. I am having trouble creating a query using the number property of the Station class.

Code:
Criteria crit = session.createCriteria(Order.class);
crit.createAlias("destination.station", "station");
crit.add(Restrictions.like("station.name", someName);


This returns an error, property "destination.station.name" not found on Order.
Is it possible to create an alias for the nested property. I can query using other primitive fields in the Location object this way.

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.