Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate - how can I map this?

 
Martin Notgonna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, is it possible to use object property values with @Filter annotation? Or any other way? I have a following problem:

Child:


Parent:


What I try to accomplish is this line:


I want to filter the collection, to leave only children with the same surname as parent. So basicly, I need a maping table, but also I need cetain entity columns to match.

How can I do this? Any other methods?
 
Alex Paransky J
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just starting out with this stuff, but could you not use a Query to return you the children with this condition? Also, according to section 9.1.26 of the JPA spec the joinColumns and inverseJoinColumns are both arrays which can take more than one column, so could you not join on id AND surname and add surname to your join table?

-AP_
 
Martin Notgonna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. I can do a separete query for the collection. That is how I'm doing it now. But I would like to do it with hibernate mappings.

2. JoinColumns is an array, but relating to the columns from the JoinTable. I need columns from tables, that the JoinTable joins ;)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic