- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下查询有效:
@Query("select o from Employee o where o.tenant.id = ?#{context.tenantId}")
@Query("select o from #{#entityName} o where o.tenant.id = 1")
但如果我同时使用这两个表达式,则会在启动时抛出异常。
@Query("select o from #{#entityName} o where o.tenant.id = ?#{context.tenantId}")
异常堆栈跟踪:
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 0): Property or field 'context' cannot be found on null
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:222)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:93)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:81)
at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:51)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:87)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299)
at org.springframework.expression.common.CompositeStringExpression.getValue(CompositeStringExpression.java:89)
at org.springframework.expression.common.CompositeStringExpression.getValue(CompositeStringExpression.java:136)
at org.springframework.data.jpa.repository.query.ExpressionBasedStringQuery.renderQueryIfExpressionOrReturnQuery(ExpressionBasedStringQuery.java:71)
at org.springframework.data.jpa.repository.query.ExpressionBasedStringQuery.<init>(ExpressionBasedStringQuery.java:48)
at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.<init>(AbstractStringBasedJpaQuery.java:57)
at org.springframework.data.jpa.repository.query.SimpleJpaQuery.<init>(SimpleJpaQuery.java:55)
at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:70)
at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromQueryAnnotation(JpaQueryFactory.java:51)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:137)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:202)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:80)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:357)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:192)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:239)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:225)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1627)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
我做错了什么还是这是一个错误?使用 spring-data-jpa 1.7.1 和 1.8.0-snapshot 进行测试。
最佳答案
这是一个错误,我已经在着手修复。我提交了 https://jira.spring.io/browse/DATAJPA-629跟踪这个。编辑:我为 JIRA 问题添加了一个修复程序 - 你介意试一试吗?
关于java - SPEL 表达式不适用于@Query 中的#{#entityName},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26911052/
SENARIO 我正在开发一个项目,将 Swift 3 合并到 Objective-C 项目中。该项目正在使用 CoreData,在我的 Objective-C AppDelegate 中,我声明了“
我使用简单的值,但我从未使用过值。(实体名称)。所以我对此感到困惑。我认为值用于获取当前值,但我在这里不明白。 public Tax Tax { get
我们在野外遇到过这种崩溃,当然我们不能在本地进行 repo 。它似乎只发生在 ios 7 上。它是一个 NSInternalInconsistencyException 的事实告诉我们这是一个内部 N
我是 coreData 编程的新手,我按照教程一步一步进行,当我收到此错误并陷入困境时,不知道这意味着什么 entityName.state must have a defined type
我正在尝试将 xml 文档加载到 C# 中的对象 XPathDocument 中。我的 xml 文档包括这一行:trés dégagée + rade当解析器到达那里时,它给了我这个错误:“解析 En
当使用“instruments”跟踪未引用的分配时,我看到了数千个 CDSnapshot[entityName]_ 实例。 这是什么?我认为它与 CoreData 相关? 最佳答案 是的,这与核心数据
我已经开始学习 Hibernate 并且有一个基本问题。 org.hibernate.Session 中的save(String entityName, Object object) 和save(Ob
以下查询有效: @Query("select o from Employee o where o.tenant.id = ?#{context.tenantId}") @Query("select o
在 Microsoft 的 Dynamics CRM 2011 实践实验室之后,我尝试将自定义 View 添加到响应特定属性的“onchange”的表单。这是我添加自定义 View 的函数: func
我发现我的代码中存在"&",这就是显示错误的原因 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(dsExport.Tables[0].R
当我设计QueryExpression 时,我总是使用以下硬编码语法。 QueryExpression expression = new QueryExpression { EntityName
我知道这可能看起来重复,但我尝试了几个答案,但所有这些都不起作用。 我正在尝试使用核心数据来存储已完成的级别,但我在保存数据时遇到了一些麻烦。当一个级别完成时,将调用以下行。 let appD
Xcode 8 在您的 NSManagedObject 子类上提供了一个自动生成的 extension,看起来像这样: // Animal+CoreDataProperties.swift impo
我正在为我的 winforms 应用程序使用自定义控制代码来创建自定义彩色进度条。我可以构建它,它工作正常,但每次我尝试使用设计器时,它都会崩溃。 “解析 EntityName 时出错” 如果我从工具
我在 Swift 2.1 和 Xcode 7.2 中使用核心数据此代码给我一个无法找到实体名称的错误。这因为 [Company] 不起作用。我有一个具有此名称的实体。 let fetchReq
我从下面的代码块中得到以下异常。 解析 EntityName 时出错。 Line1,位置 844。 我试图将从表中检索到的数据集解析为数据集。 public DataSet BindMasterDat
我有一个函数,我将一个字符串作为参数传递给名为 filterXML 的参数,其中一个属性中包含“&”。 我知道 XML 不会识别它,它会给我一个错误。这是我的代码: public XmlDocume
我正在尝试对我的实体之一的属性使用延迟加载 属性映射是这样的: 但是,当我尝试保存此实体的实例(使用 Linq)时,它会抛出 DatabaseQueryException 并带有以下内部异常: NH
我首先使用实体框架 6 代码。我有三个这样的实体: public class Doctor { public string DoctorID { get; set; } publi
我升级了一个从 ef4 开始的旧项目,但现在我将它迁移到了 ef5。 这是旧代码: protected void SaveEntity(T entity) { using (DocsM
我是一名优秀的程序员,十分优秀!