Looking for an HQL builder (Hibernate Query Language)

后端 未结 11 1097
-上瘾入骨i
-上瘾入骨i 2021-02-04 16:45

I\'m looking for a builder for HQL in Java. I want to get rid of things like:

StringBuilder builder = new StringBuilder()
    .append(\"select stock from \")
            


        
11条回答
  •  我寻月下人不归
    2021-02-04 17:41

    Criteria API does not provide all functionality avaiable in HQL. For example, you cannot do more than one join over the same column.

    Why don't you use NAMED QUERIES? The look much more clean:

    Person person = session.getNamedQuery("Person.findByName")
                                 .setString(0, "Marcio")
                                 .list();
    

提交回复
热议问题