Consider a Cat entity like this (pseudocode):
@Entity
class Cat {
@Id
Long id;
@Column
String name;
@Column
String size; /* may be "BIG", "SMALL", "TINY" see (1) */
@OneToMany
List<Cat> offsprings;
}
This HQL query, which searches by 'TINY' sized kittens
from Cat c join c.offsprings o where o.size = 'TINY'
will blow up with
ERROR: invalid input syntax for integer: "TINY"
because size
is a special property name, which will, in this case, count number of cats' offsprings.
In a scenario like this, is there a proper way to make Hibernate treat o.size
(or possibly o.class
and others) as a regular property name?
(1) I'm not an author of this regrettable design, nor do I condone it. However, I'm not in position to modify it at this moment.