Visual Paradigm Logo
     Build Quality Applications Faster, Better and Cheaper
 
Home | Products | Download | Documentation | Support | Resources | Partners | Quick Tour | Shop | Company |  
 
   Visual Paradigm Discussion Forum
  Login   [ Register ] Email: Password: Log me on automatically I lost my password  
Recent Topics
Advanced Search
Sample query to use with XXXFactory.LoadXXXByQuery(...,...)  
Forum Index -> Object Relational Mapping (ORM)
Author Message
rosdikasim@gmail.com


Joined: 2007/04/13
Messages: 9

Offline

I am trying to load an object using the generated LoadXXXByQuery. But I could not get it to understand my query string.

Example,

Code:
 
 Car car = CarFactory.LoadCarByQuery("where car.Owner.ORMID = '1'", null)
  


Basically I am trying to get a car owned by a specific Owner. But NHibernate keeps throwing exception like so..

Code:
 
 could not resolve property:Owner of :Lesen.Car [From Lesen.Car as Car Where Car.Owner.ORMID = '1']
  


Lesen is the package name for my classes.

Any code sample that explains how to use this function would be good.
 
Jick


Joined: 2005/04/29
Messages: 2880

Offline

Hello rosdikasim,

Try this:

Car car = CarFactory.LoadCarByQuery("Car.owner.id = 1", null);

PS. Notice that the statement is case sensitive. We assume that Car starts with capital letter 'C', and owner starts with small letter 'o'.

Best regards,
Jick

Visual Paradigm International Ltd.
http://www.visual-paradigm.com

Build Quality Applications Faster, Better and Cheaper
 
rosdikasim@gmail.com


Joined: 2007/04/13
Messages: 9

Offline

Duh!.. I didnt realize that I am supposed to refer to the "name" property in the mapping file and not the class name!

So the correct query is "Car.ORM_Owner.Id = 1"

Everything work fine now. TQ.
 
Jick


Joined: 2005/04/29
Messages: 2880

Offline

You are welcome!

Visual Paradigm International Ltd.
http://www.visual-paradigm.com

Build Quality Applications Faster, Better and Cheaper
 
 
   Forum Index -> Object Relational Mapping (ORM)
Go to:   
Powered by JForum 2.1.4 © 2005 - Rafael Steil