Two tables that this problem relates to are BUSINESS and BUSINESS_KEYWORD. The keyword table contains a BUSINESS_ID and a KEYWORD (string value). The idea is that we can associate keywords to businesses and search for a business by that keyword (where keyword like 'food%' say). I have it mapped currently as a bag:
Code:
<bag name="keywords"
lazy="true"
inverse="false"
table="BUSINESS_KEYWORD"
cascade="all-delete-orphan"
order-by="KEYWORD ASC">
<key column="BUSINESS_ID" />
<element column="KEYWORD" type="string" />
</bag>
The sorting is for administrative use only (easier to find one out of a 100 if they're sorted). Anyway, I basically want to do an SQL query like:
Code:
SELECT ...
FROM BUSINESS, BUSINESS_KEYWORD
WHERE BUSINESS.BUSINESS_ID = BUSINESS_KEYWORD.BUSINESS_ID AND
BUSINESS_KEYWORD.KEYWORD LIKE 'food%'
I can't find anything in the Hibernate doco's about how to do a query like this though. All the examples are indexed bags. Is there any way to do something like:
Code:
from com.sa.go.bto.Business b
where b.keywords like 'food%'
(or b.keywords[], b.keywords[%], ...)
Thanks!
James