Tag: concat

JPA CriterialBuilder.concat强制使用concat函数

我正在使用CriteriaBuilder.concat连接2个字符串,使用下面的代码: Expression concat = criteriaBuilder.concat(expr1, expr2) 但生成的SQL类似于: select distinct col_1 || col_2 导致org.hibernate.hql.ast.QuerySyntaxException : expecting CLOSE, found ‘||’ near line 1, column 48 [ select count(distinct generatedAlias0.hostname || generatedAlias0.device) from … ^(1,48) 我想知道如何强制它生成以下使用concat()函数而不是|| SQL 运营商? select distinct concat(col_1, col_2) 更新: 从错误我们可以看出Hibernate( v3.6.10.Final )方面的问题更多,这就是为什么让MySQL接受|| 连接没有帮助,更新到更新的版本不是我的选择。 谢谢

字符串Concat具有相同的参考?

这是我的代码,我现在对此输出的字符串池和堆存储非常困惑。 public class String1 { public static void main(String[] args) { // TODO Auto-generated method stub String str = “abcd”; String str1 = “” ; str1=str1+”abcd”; if(str.equals(str1)) System.out.println(“True”); else System.out.println(“False”); if(str == str1) System.out.println(“True”); else System.out.println(“False”); } } 现在,我正在创建String str并将存储在字符串池中(如果我出错了,请纠正我!)。 现在在concat str1使用字符串”abcd”它们都具有相同的值。 所以,我认为str和str1应该在String池中具有相同的引用,因此, if语句应该打印为true ,则它会打印为false 。 那么,我的问题为什么str和str1没有得到相同的参考?

JSF EL表达式中的Concat两个字符串

我有以下表达式: 但我得到了 java.lang.NumberFormatException: For input string: “Publish on ” 我该如何加入字符串?