-->
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: Querying with Filters
PostPosted: Fri Dec 10, 2010 11:29 am 
Beginner
Beginner

Joined: Fri Nov 13, 2009 4:05 pm
Posts: 30
I have the following three entities described below. I want to be able to query my transaction entity and apply a filter to my text collection inside item so that the texts are locale specific based on the current user's session. How can I do this?

Code:
@Entity
public class Transaction {
  @ManyToOne(fetch=FetchType.EAGER)
  @JoinColumns({@JoinColumn(name="item_id",insertable=false,updatable=false),@JoinColumn(name="pid",insertable=false,updatable=false)})
  public Item getItem() { return this.item }
  public void setItem(Item item) { this.item = item; }
}

@Entity
public class Item {
  @OneToMany(fetch=FetchType.LAZY,mappedBy="item")
  public List<ItemText> getTexts() { return this.texts; }
  public void setTexts(List<ItemText> texts) { this.texts = texts; }
}

@Entity
public class ItemText {
  @Column(name="language_code",length=10)
  public String getLanguageCode() { return this.languageCode; }
  public void setLanguageCode(String languageCode) { this.languageCode = languageCode; }
}


If I were to place the necessary filter annotations on my ItemText object, I cannot enable this filter because my query is actually being applied against my Transaction class using session.createCriteria(Transaction.class).

Any thoughts?


Top
 Profile  
 
 Post subject: Re: Querying with Filters
PostPosted: Mon Dec 13, 2010 6:15 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I don't think you are on the right forum. This forum is about Hibernate Search and Validator. Unless of course I misunderstand your question.
By the way, when it comes to criteria queries you can easily navigating associations using additional createCriteria() calls - session.createCriteria(Transaction.class).createCriteria("item").createCriteria("texts"). Something like this. Have a look at the online documentation for Hibernate Core.

--Hardy


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.