Is there a way to avoid the name of the size property in HQL?

Consider a Cat object 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 is an HQL query that looks for kittens of size "TINY"

from Cat c join c.offsprings o where o.size = 'TINY'

explode with

ERROR: Invalid input syntax for integer: "TINY"

because size- this is a special property name, which in this case counts the number of descendants of cats.

In a scenario like this, is there a proper way to force Hibernate to heal o.size(or perhaps o.classothers) as a regular property name?


(1) I am not the author of this sad design, and I cannot indulge it. However, I cannot change it at the moment.

+4
source share

Source: https://habr.com/ru/post/1629199/


All Articles