-->
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: Problems with criteria and many-to-one
PostPosted: Wed Dec 05, 2007 12:59 pm 
Newbie

Joined: Mon Aug 28, 2006 4:08 pm
Posts: 2
Location: Brazil
Hello,

I have a Foreign Key that is a Primary Key. I did:
Code:
@Embeddable
public class PersonPk implements Serializable {
@ManyToOne(optional=false, cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="psId")
private Person person;

// gets and sets
}


My user table that uses PersonPk
Code:
@Entity @Table
public class User {
   @Id
   private PersonPk pk = new PersonPk();
        // gets and sets
}


Now I want to find users with the name John... I'm trying this:
Code:
Criteria c = session.createCriteria(User.class);
c.setFetchMode("pk.person", FetchMode.JOIN);
c.createAlias("pk.person", "person");
c.add(Expression.ilike("person.name", "John"));


But doesn't works.. JOIN was not made. How can I do? I'm not using inheritance because I need share person's id, with another tables.


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.