-->
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.  [ 2 posts ] 
Author Message
 Post subject: Join problem in criteria query
PostPosted: Mon Mar 16, 2015 3:18 pm 
Newbie

Joined: Mon Mar 16, 2015 3:02 pm
Posts: 1
Hello!

I have such problem with criteria query:

I have the following entities:

Code:
@Entity
@Table(name="vacancies")
public class Vacancy {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name="id")
    private Long id;

    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private VacancyCity city;

    /* Getters and setters located at bottom */
}

@Entity
@Table(name="vacancies_cities")
public class VacancyCity {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name="id")
    private Long id;

    @Column(name="title")
    private String title;

    /* Getters and setters located at bottom */
}


But why when I do criteria query with restrictions class I get such exception: Exception in thread "main" org.hibernate.QueryException: could not resolve property: city.title of: np.data.models.Vacancy

Query:
Code:
session.createCriteria(np.data.models.Vacancy.class).add(Restrictions.eq("city.title", "New york")).list();


Thank you!


Top
 Profile  
 
 Post subject: Re: Join problem in criteria query
PostPosted: Tue Mar 17, 2015 11:14 pm 
Newbie

Joined: Tue Mar 17, 2015 9:53 pm
Posts: 4
I believe that syntax is used for embedded components and doesn't work for associated entities.


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