Looking for an HQL builder (Hibernate Query Language)

后端 未结 11 905
-上瘾入骨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:24

    I know this thread is pretty old, but I also was looking for a HqlBuilder And I found this "screensaver" project
    It is NOT a Windows screensaver, it's a "Lab Information Management System (LIMS) for high-throughput screening (HTS) facilities that perform small molecule and RNAi screens."

    It contains an HQLBuilder that is looking quite good.
    Here is a sample list of available methods:

    ...
    HqlBuilder select(String alias);
    HqlBuilder select(String alias, String property);
    HqlBuilder from(Class entityClass, String alias);
    HqlBuilder fromFetch(String joinAlias, String joinRelationship, String alias);
    HqlBuilder where(String alias, String property, Operator operator, Object value);
    HqlBuilder where(String alias, Operator operator, Object value);
    HqlBuilder where(String alias1, Operator operator, String alias2);
    HqlBuilder whereIn(String alias, String property, Set values);
    HqlBuilder whereIn(String alias, Set values);
    HqlBuilder where(Clause clause);
    HqlBuilder orderBy(String alias, String property);
    HqlBuilder orderBy(String alias, SortDirection sortDirection);
    HqlBuilder orderBy(String alias, String property, SortDirection sortDirection);
    String toHql();
    ...
    

提交回复
热议问题