tags:

views:

21

answers:

0

I'm wondering if the following is feasible in Hibernate ; when writing an HQL query, you can say things like

select foo from Foo where foo.barString like "%baz%"

This works assuming that class Foo has a String attribute called barString.

Now, assume that Foo as a bar attribute of type Bar, but that Bar has a well-known, canonical String representation. Assume that this is something that can easily and quickly computed (say, by concatenation), but that it is not stored in the DB. Is there a way to map / modify the class so that you can write something like either

 select foo from Foo where foo.bar like "%baz%"

or

 select foo from Foo where foo.bar.toCanonicalString like "%baz%"

or even

 select foo from Foo where toCanonicalString(foo.bar) like "%baz%"

?

Thanks PH