Last active
September 1, 2016 07:32
-
-
Save springcome/92824e8c1e5485260dffe13296b1e718 to your computer and use it in GitHub Desktop.
The use of 'CaseBuilder()' example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// String compare, Result Long | |
// query().from(cat).list(cat.name.when("Bob").then(1).otherwise(2)); | |
// java.lang.ClassCastException: org.hibernate.hql.ast.tree.ParameterNode cannot be cast to org.hibernate.hql.ast.tree.SelectExpression | |
// https://github.com/querydsl/querydsl/issues/185 | |
query().from(cat).list(cat.name.when("Bob").then(Expressions.numberTemplate(Long, "1")).otherwise(Expressions.numberTemplate(Long, "2"))); | |
// String hour compare, Result String | |
StringExpression amPm = new CaseBuilder().when(o.hour.lt("1200")).then("AM").otherwise("PM"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment