• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@OneToMany Hibernate 3 @Filters not working

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Thanks in advance to any pointers and info.

I have a DB schema design which uses �Soft/virtual Deletes� where every table has a column �del_ind�(number) which indicates(1/0) whether a row is considered �deleted� or not. If the app wants a row to be �deleted�, it then sets it to 1. On normal insertion, this column is set to �0�.

I am using Hibernate 3 annotations(@FilterDef, @Filter) to filter out Objects that have the �delete_ind� column set to value 1. The Filter is working for the Main Domain Object. But the Filter is not working for the dependent child Object(association).

Details
=======

I have a �Plan� Class that has a OneToMany relationship with �Customer�



I am able to apply the Filter to the Main Entity "PlanImpl". Th filter works just fine. But when I apply the Filter to the association of @OneToMany association of Plan to PlanCustomer, the Filter does not work.

Does anyone know what I need to do to get it right. Google did not do the trick this time around.

Thank you so much,

BR,
~A
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have never done this, so my suggestion is just a complete guess. But what happens if the filter is put at the class level for all the mapped classes, instead of Annotating the OneToMany

For instance, the PlanCustomer class has its filter in that class, rather than on the private Set<PlanCustomer> planCustomers = new HashSet<PlanCustomer>();

or, maybe for the OneToMany the field to filter on remains the same as what is in the class level.

Mark
 
anjan bachchu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

Thanks for the reply.

I have never done this, so my suggestion is just a complete guess. But what happens if the filter is put at the class level for all the mapped classes, instead of Annotating the OneToMany.



Since Each Entity in our Table has a similar BUT slightly different column names(ASSRT_PLAN_DEL_IND, ASSRT_PLAN_CUST_DEL_IND, etc), using the same Filter across multiple classes is not feasible.


For instance, the PlanCustomer class has its filter in that class, rather than on the private Set<PlanCustomer> planCustomers = new HashSet<PlanCustomer>();

or, maybe for the OneToMany the field to filter on remains the same as what is in the class level.

Mark



Given the fact that the column on each table has a different name in each table, I believe that I won't be able to apply this advice.

Thanks for any suggestions.

BR,
~A
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't say use the same field name. I said don't put it all in the same class.

So the annotation for each class would have the field that is specific to that class.

Mark
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic