-->
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: @Formula is ignored
PostPosted: Tue Jun 08, 2010 6:18 pm 
Newbie

Joined: Tue Jun 08, 2010 6:00 pm
Posts: 1
Hello world !

I'm using Hibernate core 3.3.2GA with Hibernate annotations 3.4.0.GA. I have a Team Entity with 2 attributes, city and nickname. I want so search my Teams with a concatenation of both fields, for example "Los Angeles Lakers". I guess I can use @Formula for this but it doesn't work.

Code:
@Entity
@XmlRootElement(name = "team")
public class Team
{
   private String nickname;

   private String city;

   @Formula(value = "CONCAT(city,\" \",nickname)")
   private String cityAndNickname;

   @Column
   public String getCity()
   {
      return city;
   }

   @Column
   public String getNickname()
   {
      return nickname;
   }
...
}


I have tried different things, but when I query my db
Code:
Criteria criteria=sessionFactory.getCurrentSession().createCriteria(Team.class);
criteria.add(Restrictions.eq("cityAndNickname", teamCityPlusNickname));


I get the error "could not resolve property: cityAndNickname"

Any idea of what is wrong here ?

Thanks

--
Vincent


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.