-->
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: Hibernate 4: ManyToMany with @FilterJoinTable-Annotation
PostPosted: Wed May 29, 2013 3:53 am 
Newbie

Joined: Tue May 28, 2013 9:25 am
Posts: 2
We are using the @FilterJoinTable-Annotation for Filtering @ManyToMany-Entities.
Code:
...
    @ManyToMany(targetEntity = StructureNodeVO.class)
    @JoinTable(name = "editor_einstiegsordner", joinColumns = { @JoinColumn(name = "usr", referencedColumnName = "id"),
        @JoinColumn(name = "cusid", referencedColumnName = "cusid", nullable = false) }, inverseJoinColumns = @JoinColumn(name = "gruppe_ordner"))
    @FilterJoinTables({ @FilterJoinTable(name = "archiv"), @FilterJoinTable(name = "owner") })
    @Filters({ @Filter(name = "archiv"), @Filter(name = "owner") })
    private Set<GruppeOrdnerVO> gruppeneditorEinstiegsordner = new HashSet<GruppeOrdnerVO>();
...

We defined the Filter's for "archiv" and "owner" in a separate Class.
Code:
...
@org.hibernate.annotations.FilterDef(name = "archiv", defaultCondition = "archiv = 'false'"),
@org.hibernate.annotations.FilterDef(name = "owner", defaultCondition = "cusid = :ownerid", parameters = @org.hibernate.annotations.ParamDef(
            name = "ownerid", type = "long")),
...

While using hibernate 3.6 everything works as expected. Since we upgraded to hibernate 4.2.1, we had to add the defaultCondition of the Filter-Definition to the FilterJoinTable-Annotation:
@FilterJoinTables({ @FilterJoinTable(name = "archiv", condition="archiv = 'false'"), @FilterJoinTable(name = "owner", condition="cusid = :ownerid") })

The cause of this seems to be HHH-2394. There was a little adjustment to the org.hibernate.cfg.annotations.CollectionBinder.bindFilters(boolean)-Method, according the @FilterJoinTable-condition is written into filter-collection.

The relevant commit is https://github.com/hibernate/hibernate-orm/commit/05dcc209ae44dfa1fc39da67463a603d44199ba9#hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java, Line 833

Has anybody an explantaion why this adjustments where necessary? Or is this a bug (it seems to be a bug, but I am not sure)?


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.