Reputation: 561
Im having domain object Item with fields id, name, parentItem and category(Boolean). So im inserting values in database like:
id name parentItem category
1 Tools NULL 1
2 Electric tools 1 1
3 Small tools 2 1
4 Actual tool end child item 3 0
so actual item is in category/path "Tools/Electric tools/Small tools"
So i need to implements lazy filter search by categoryName/categoryPath. For example: if user inputs in dataTable filter "Electric" i need to return all items in "Electric tools" category and all items from subcategorys ( in this example Small tools and all other if they exist).
So currently i have in java domain object @Transient field which uses recursion to get items path.
But i cant search by Transient fields. I mean i cant implement search in database because this field is:
1. Transient
2. Uses recursion and if i need to deploy app on other db version, i will have to rewrite recursion sql on db or something. I dont like this
Can anyone point me to some clever, unique solution ? Any idea, advice is appreciated. Thanks!
Upvotes: 1
Views: 1175
Reputation: 3884
This question looks very similar: HQL recursion, how do I do this?
In short: You cannot do recursion in HQL. Your best bets are:
Upvotes: 1