-->
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: Querying with Filters
PostPosted: Fri Dec 10, 2010 11:30 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  
 
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.