4.5.1也是4.0和4.5的就地升级吗?(Is 4.5.1 also in-place upgrade of 4.0 and 4.5?)
现在我们有.NET framework 4.5.1。 只是想知道4.5.1是否也是4.0和4.5的“就地升级”?
Now we have .NET framework 4.5.1. Just curious to know whether the 4.5.1 is also an "in place upgrade" for 4.0 and 4.5?
原文:
最满意答案
我不认为这是可能的,
LIKE
的左边部分应该是一个string_expression (在标准的JPA中)。 从规格:4.6.9类似表达式
在条件表达式中使用比较运算符[NOT] LIKE的语法如下所示:
string_expression [NOT] LIKE pattern_value [ESCAPE escape_character]
string_expression必须有一个字符串值。 pattern_value是字符串文字或字符串值输入参数,其中下划线(_)代表任何单个字符,百分号(%)代表任何字符序列(包括空序列),所有其他字符代表为了自己。 可选的escape_character是单字符字符串文字或字符值输入参数(即
char
或Character
),用于转义pattern_value中下划线和百分号字符的特殊含义。而enum_expression不是一个string_expression 。
以下工作虽然(使用枚举文字 ):
SELECT f FROM Foo f WHERE f.bar = com.acme.Bar.SOME_CONSTANT OR f.bar = com.acme.Bar.SOME_OTHER_CONSTANT
另一个选择是将
bar
栏实际存储为一个String
(并且在getter / setter中进行一些转换并将其转换为enum)。参考
- JPA 1.0规范
- 第4.6.9节“像表达式”
- 第4.14节“BNF”
I don't think it's possible, the left part of a
LIKE
is supposed to be a string_expression (in standard JPA). From the specification:4.6.9 Like Expressions
The syntax for the use of the comparison operator [NOT] LIKE in a conditional expression is as follows:
string_expression [NOT] LIKE pattern_value [ESCAPE escape_character]
The string_expression must have a string value. The pattern_value is a string literal or a string-valued input parameter in which an underscore (_) stands for any single character, a percent (%) character stands for any sequence of characters (including the empty sequence), and all other characters stand for themselves. The optional escape_character is a single-character string literal or a character-valued input parameter (i.e.,
char
orCharacter
) and is used to escape the special meaning of the underscore and percent characters in pattern_value.And an enum_expression is not a string_expression.
The following would work though (using enum literals):
SELECT f FROM Foo f WHERE f.bar = com.acme.Bar.SOME_CONSTANT OR f.bar = com.acme.Bar.SOME_OTHER_CONSTANT
Another option would be to actually store the
bar
field as aString
(and to do some conversion from and to an enum in the getter/setter).Reference
- JPA 1.0 Specification
- Section 4.6.9 "Like Expressions"
- Section 4.14 "BNF"
相关问答
更多-
您需要使用三角形括号作为内核启动语法的一部分: findMinMax<<
>>(lum,&min_logLum,&max_logLum); 这应该解决编译错误,前提是其余的是正确的(例如,参数集与内核原型匹配)。 请注意,启动内核的方式还有一些其他问题: 您将每个网格的块数减少而不是向上。 例如,如果sizeof(lum)计算结果为1500,则仍然只启动1个1024个线程的块。 这可能不是你打算做的。 您将主机指针&min_logLum和&max_logLum传 ... -
假设您认为Name属性是string而不是int ( ( IEnumerable
)Enum.GetValues(typeof(Colors)) ) .Select(ev => new Color() { Value = ev, Name = Enum.GetName(typeof(Colors), ev) }) .ToList(); Assumes you meant for the Name property to be ... -
如何在Hibernate / HQL / JPQL中通过客户表达来订购结果(How to order results by customer expression in Hibernate/HQL/JPQL)[2024-02-22]
我刚刚写了一个测试类,并在Hibernate / JPA 3.6.1中做了以下工作: SELECT o FROM Cat o ORDER BY CASE o.name WHEN 'Tom' THEN 0 ELSE 1 END I've just written a test class and the following works in Hibernate/JPA 3.6.1: SELECT o FROM Cat o ORDER BY CASE o.name WHEN 'Tom' T ... -
您发布的代码对我来说看起来很不错,CodePad在快速测试中编译它就好了。 所以虽然这个问题没有提到它,但我会猜测你在Visual Studio中工作。 在这种情况下,您看到的错误很可能是IntelliSense错误,而不是实际的编译器错误。 有时,IntelliSense引擎(使用不同的编译器实现)会感到困惑并报告您已经在代码中修复的错误。 重构现有代码时,我经常会注意到这个问题。 解决的办法是建立/编译你的项目并验证错误消失。 重建后应该会看到一个干净的“错误列表”窗口。 The code you've ...
-
对于命名查询,(ORDER BY(a.id =:id)或ORDER BY(:id))将不起作用,因为DSC / ASC无法在运行时进行参数化。 1)如果排序元素在运行时变化,动态方式。 String query = "SELECT a FROM Article a ORDER BY "+orderElement+" DESC, a.id DESC"; entityManager.createQuery(query).getResultList(); 2)如果订购元素是固定的,则在实体bean中使用静态方式 ...
-
我可以通过将枚举值转换为整数来解决其他地方,但这似乎是错误的,不知何故。 它不应该感到错误。 毕竟,这就是编译器本身所做的事情 - 它要么将枚举值替换为相应的数值(当枚举值在编译时已知),要么生成在运行时执行必要强制转换的代码。 请注意,这些强制转换不一定是int ,而是有问题的枚举的支持类型。 如果我可以在C#中的MyEnum值之间进行比较操作,那么为什么Expression构建器不允许它呢? 您正在构建的表达式树看起来与C#代码中发生的情况相匹配,但实际上并非如此 - 正是因为编译器在幕后工作所做的如上 ...
-
不幸的是,您不能(直接)将case条件用作Bool表达式。 它们只能在if , guard , while , for等语句中访问。 这在语言语法中有详细说明,包括: case-condition → case pattern initializer 然后在以下condition : condition → expression | availability-condition | case-condition | optional-binding-condition (其中expression ...
-
请检查以下内容。 if activity.activity_type?.id == LHActivityTypeID.Bike.rawValue { self?.allItems.append(activity) } Please check the below. if activity.activity_type?.id == LHActivityTypeID.Bike.rawValue { self?.allItems.append(activity) }
-
没有,通常没有办法引用任何类中的字段,也不可能将参数传递给SELECT子句。 只有构造函数表达式的有效参数是(来自JPA 2.0规范,第174页) single_valued_path_expression scalar_expression aggregate_expression identification_variable No there is not, in general there is no way to reference to the fields in any class and i ...
-
枚举上的JPQL LIKE表达式(JPQL LIKE expression on enum)[2024-04-20]
我不认为这是可能的, LIKE的左边部分应该是一个string_expression (在标准的JPA中)。 从规格: 4.6.9类似表达式 在条件表达式中使用比较运算符[NOT] LIKE的语法如下所示: string_expression [NOT] LIKE pattern_value [ESCAPE escape_character] string_expression必须有一个字符串值。 pattern_value是字符串文字或字符串值输入参数,其中下划线(_)代表任何单个字符,百分号(%)代表 ...