-->
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.  [ 4 posts ] 
Author Message
 Post subject: Transient field returns "could not resolve property" error
PostPosted: Fri Nov 05, 2010 2:42 pm 
Newbie

Joined: Fri Jul 16, 2010 8:20 am
Posts: 4
Transient method returns "could not resolve property".

Code:
public class  Me {

    private Long id;
    private String username;                         
    private Car mycar = new Car();

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }


@Transient
    public Car getMycar() {
        return mycar;
    }

    public void setMycar(Car mycar) {
        this.mycar = mycar;
    }
}

public class Car {
    private Long id;
    private String model;
    private String mileage;
    private String cost;

   Assuming all the getter and setters are already coded....
}



The following is my getHibernateTemplate() using HQL.
Code:
public List<Me> findCars(String username, String cost) {
   getHibernateTemplate().find("from Me as m where m.username='"+username+"' and m.mycar.cost='"+cost+"'");
}


The following is my error message.
Code:
could not resolve property: mycar of: com.app.model.Me [from com.app.model.Me as m where m.username='jack' and m.mycar.cost='40000']; nested exception is org.hibernate.QueryException: could not resolve property: mycar of: com.app.model.Me [from com.app.model.Me as m where m.username='jack' and m.mycar.cost='40000']


Can anyone help me to resolve this error? Thanks.


Top
 Profile  
 
 Post subject: Re: Transient field returns "could not resolve property" error
PostPosted: Sat Nov 06, 2010 12:24 pm 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Show your mapping file.


Top
 Profile  
 
 Post subject: Re: Transient field returns "could not resolve property" error
PostPosted: Sat Nov 06, 2010 3:41 pm 
Newbie

Joined: Fri Jul 16, 2010 8:20 am
Posts: 4
Hi, Thanks for the reply.

From this url
viewtopic.php?p=2250284

It mentions that

Code:
transient properties are neither persisted nor queryable.


So does that means that by declaring my fields as transient, I cannot use them in my HQL at all since they are neither persisted nor queryable?

Sorry if my question sound stupid because I am new to all these. Thanks for helping.


Top
 Profile  
 
 Post subject: Re: Transient field returns "could not resolve property" error
PostPosted: Sat Nov 06, 2010 5:40 pm 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Yes, there is no point to query transient field and very strange thing to do. When you mark something transient you, basically, say that you are not storing the property to the database. So there is no point trying to find it out through HQL.


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