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: Criteria with transient property
PostPosted: Wed Aug 29, 2012 10:47 am 
Newbie

Joined: Tue Aug 28, 2012 10:03 pm
Posts: 1
I have am Employee entity and a Location entity. When retrieving a list of Employees, I would like to also retrieve
each employee's current location.
For various reasons, I do not want to persist the location as part of the Employee entity.
Instead, I would like to lookup each Employee's location when retrieving a list of employees.
I would like for each employee's locationName to be part of the Employee object returned by
the Criteria query.

I thought to add a transient property to the Employee entity(see below) and set it when
retrieving a list of Employee, but that results in an error org.hibernate.QueryException: could not resolve property: locationName of: com.csc.apps.contacts.model.Employee

Any ideas?


@Entity
public class Employee
{
@Id
private String employeeNumber;

private int locationId;

@Transient
private String locationName;
}

@Entity
public class Location
{
@ID
private int locationId;
private String locationName;
}


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.