- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我的存储库 bean 尝试初始化时,我的 JQL 查询出现语法错误消息:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: order near line 1, column 17 [select distinct order from com.github.eljah.mental.domain.Order order left join fetch order.shipments left join fetch order.subscriptions]
由Spring data repo中的这部分引起:
@Query("select distinct order from Order order left join fetch order.shipments left join fetch order.subscriptions")
完整的输出附在下面。
Spring 数据存储库类:
@Repository
public interface OrderRepository extends JpaRepository<Order, Long>, JpaSpecificationExecutor<Order> {
@Query("select order from Order order where order.user.login = ?#{principal.username}")
List<Order> findByUserIsCurrentUser();
@Query(value = "select distinct order from Order order left join fetch order.shipments left join fetch order.subscriptions",
countQuery = "select count(distinct order) from Order order")
Page<Order> findAllWithEagerRelationships(Pageable pageable);
@Query("select distinct order from Order order left join fetch order.shipments left join fetch order.subscriptions")
List<Order> findAllWithEagerRelationships();
@Query("select order from Order order left join fetch order.shipments left join fetch order.subscriptions where order.id =:id")
Optional<Order> findOneWithEagerRelationships(@Param("id") Long id);
}
实体本身是:
@Entity
@Table(name = "jhi_order")
@org.springframework.data.elasticsearch.annotations.Document(indexName = "shipment", shards = 1, replicas = 0, refreshInterval = "-1")
public class Order implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
@org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Keyword)
private Long id;
@Column(name = "created")
private ZonedDateTime created;
@Column(name = "paid")
private ZonedDateTime paid;
@Column(name = "processed")
private Boolean processed;
@Column(name = "md_order")
private String mdOrder;
@Column(name = "operation")
private String operation;
@ManyToOne(optional = false)
@NotNull
@JsonIgnoreProperties("orders")
private User user;
@ManyToMany
@JoinTable(name = "jhi_order_shipments",
joinColumns = @JoinColumn(name = "order_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "shipments_id", referencedColumnName = "id"))
private Set<Shipment> shipments = new HashSet<>();
@ManyToMany
@JoinTable(name = "jhi_order_subscriptions",
joinColumns = @JoinColumn(name = "order_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "subscriptions_id", referencedColumnName = "id"))
private Set<AccessSubscription> subscriptions = new HashSet<>();
setters/getters 被省略了。那么,那里出了什么问题?对于具有类似 JQL 查询的类似实体,我有类似的 SpringData 存储库,一切正常。或者“顺序”可能是 JQL 中的一种关键工作?
| 2019-09-25 18:00:01.145 ERROR 8 --- [ main] o.h.hql.internal.ast.ErrorTracker : line 1:119: unexpected token: order
mental-app_1 |
mental-app_1 | antlr.NoViableAltException: unexpected token: order
mental-app_1 | at org.hibernate.hql.internal.antlr.HqlBaseParser.joinPath(HqlBaseParser.java:1760)
mental-app_1 | at org.hibernate.hql.internal.antlr.HqlBaseParser.fromJoin(HqlBaseParser.java:1640)
mental-app_1 | at org.hibernate.hql.internal.antlr.HqlBaseParser.fromClause(HqlBaseParser.java:1355)
mental-app_1 | at org.hibernate.hql.internal.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1063)
mental-app_1 | at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:748)
mental-app_1 | at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:319)
mental-app_1 | at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:198)
mental-app_1 | at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:289)
mental-app_1 | at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:188)
mental-app_1 | at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:143)
mental-app_1 | at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:119)
mental-app_1 | at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
mental-app_1 | at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153)
mental-app_1 | at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:611)
mental-app_1 | at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:720)
mental-app_1 | at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:104)
mental-app_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
mental-app_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
mental-app_1 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
mental-app_1 | at java.base/java.lang.reflect.Method.invoke(Unknown Source)
mental-app_1 | at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350)
mental-app_1 | at com.sun.proxy.$Proxy173.createQuery(Unknown Source)
mental-app_1 | at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:87)
mental-app_1 | at org.springframework.data.jpa.repository.query.SimpleJpaQuery.<init>(SimpleJpaQuery.java:63)
mental-app_1 | at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:76)
mental-app_1 | at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromQueryAnnotation(JpaQueryFactory.java:56)
mental-app_1 | at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:142)
mental-app_1 | at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:209)
mental-app_1 | at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:79)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lookupQuery(RepositoryFactorySupport.java:566)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(RepositoryFactorySupport.java:559)
mental-app_1 | at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
mental-app_1 | at java.base/java.util.Iterator.forEachRemaining(Unknown Source)
mental-app_1 | at java.base/java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Unknown Source)
mental-app_1 | at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
mental-app_1 | at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
mental-app_1 | at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
mental-app_1 | at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
mental-app_1 | at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
mental-app_1 | at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.mapMethodsToQuery(RepositoryFactorySupport.java:561)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$new$0(RepositoryFactorySupport.java:551)
mental-app_1 | at java.base/java.util.Optional.map(Unknown Source)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:551)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:324)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:297)
mental-app_1 | at org.springframework.data.util.Lazy.getNullable(Lazy.java:211)
mental-app_1 | at org.springframework.data.util.Lazy.get(Lazy.java:94)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:300)
mental-app_1 | at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:121)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
mental-app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
mental-app_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
mental-app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251)
mental-app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
mental-app_1 | at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
mental-app_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
mental-app_1 | at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:218)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1341)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1187)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
mental-app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
mental-app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
mental-app_1 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
mental-app_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
mental-app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
mental-app_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
mental-app_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)
mental-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
mental-app_1 | at com.github.eljah.mental.MentalApp.main(MentalApp.java:63)
mental-app_1 |
mental-app_1 | 2019-09-25 18:00:01.153 WARN 8 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderQueryService' defined in file [/app/classes/com/github/eljah/mental/service/OrderQueryService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.github.eljah.mental.repository.OrderRepository.findAllWithEagerRelationships()!
mental-app_1 | 2019-09-25 18:00:01.361 ERROR 8 --- [ main] o.s.boot.SpringApplication : Application run failed
mental-app_1 |
mental-app_1 | org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderQueryService' defined in file [/app/classes/com/github/eljah/mental/service/OrderQueryService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.github.eljah.mental.repository.OrderRepository.findAllWithEagerRelationships()!
mental-app_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769)
mental-app_1 | at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:218)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1341)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1187)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
mental-app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
mental-app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
mental-app_1 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
mental-app_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
mental-app_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
mental-app_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
mental-app_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)
mental-app_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
mental-app_1 | at com.github.eljah.mental.MentalApp.main(MentalApp.java:63)
mental-app_1 | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.github.eljah.mental.repository.OrderRepository.findAllWithEagerRelationships()!
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
mental-app_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
mental-app_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
mental-app_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
mental-app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251)
mental-app_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
mental-app_1 | at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
mental-app_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
mental-app_1 | ... 17 common frames omitted
mental-app_1 | Caused by: java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.github.eljah.mental.repository.OrderRepository.findAllWithEagerRelationships()!
mental-app_1 | at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:93)
mental-app_1 | at org.springframework.data.jpa.repository.query.SimpleJpaQuery.<init>(SimpleJpaQuery.java:63)
mental-app_1 | at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:76)
mental-app_1 | at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromQueryAnnotation(JpaQueryFactory.java:56)
mental-app_1 | at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:142)
mental-app_1 | at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:209)
mental-app_1 | at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:79)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lookupQuery(RepositoryFactorySupport.java:566)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(RepositoryFactorySupport.java:559)
mental-app_1 | at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
mental-app_1 | at java.base/java.util.Iterator.forEachRemaining(Unknown Source)
mental-app_1 | at java.base/java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Unknown Source)
mental-app_1 | at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
mental-app_1 | at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
mental-app_1 | at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
mental-app_1 | at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
mental-app_1 | at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
mental-app_1 | at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.mapMethodsToQuery(RepositoryFactorySupport.java:561)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$new$0(RepositoryFactorySupport.java:551)
mental-app_1 | at java.base/java.util.Optional.map(Unknown Source)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:551)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:324)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:297)
mental-app_1 | at org.springframework.data.util.Lazy.getNullable(Lazy.java:211)
mental-app_1 | at org.springframework.data.util.Lazy.get(Lazy.java:94)
mental-app_1 | at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:300)
mental-app_1 | at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:121)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
mental-app_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
mental-app_1 | ... 28 common frames omitted
mental-app_1 | Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: order near line 1, column 17 [select distinct order from com.github.eljah.mental.domain.Order order left join fetch order.shipments left join fetch order.subscriptions]
mental-app_1 | at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138)
mental-app_1 | at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
mental-app_1 | at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
mental-app_1 | at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:729)
mental-app_1 | at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:104)
mental-app_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
mental-app_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
mental-app_1 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
mental-app_1 | at java.base/java.lang.reflect.Method.invoke(Unknown Source)
mental-app_1 | at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350)
mental-app_1 | at com.sun.proxy.$Proxy173.createQuery(Unknown Source)
mental-app_1 | at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:87)
mental-app_1 | ... 57 common frames omitted
mental-app_1 | Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: order near line 1, column 17 [select distinct order from com.github.eljah.mental.domain.Order order left join fetch order.shipments left join fetch order.subscriptions]
mental-app_1 | at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74)
mental-app_1 | at org.hibernate.hql.internal.ast.ErrorTracker.throwQueryException(ErrorTracker.java:93)
mental-app_1 | at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:296)
mental-app_1 | at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:188)
mental-app_1 | at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:143)
mental-app_1 | at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:119)
mental-app_1 | at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
mental-app_1 | at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153)
mental-app_1 | at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:611)
mental-app_1 | at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:720)
mental-app_1 | ... 65 common frames omitted
最佳答案
单词 order
(您似乎试图在查询中用作变量名)是 JPQL 保留字。请改用o
,我强烈建议您考虑将“当前用户”外部化,以便您将用户或用户ID 作为参数传入并在别处解析;在 @Query
中执行此操作会引入难以测试的硬耦合。
关于java - 由 : org. hibernate.hql.internal.ast.QuerySyntaxException : unexpected token: order near line 1, 第 17 列引起,原因不明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58104588/
我有实体和 NamedQuery: @Entity @Table(name="MY_TABLE") @NamedQueries({ @NamedQuery(name="myQuery", quer
hql 中的 row_number() 与分区的等价物是什么 我在 hql 中有以下查询: select s.Companyname, p.Productname, sum(od.Unitprice
hql 函数 current_timestamp() 使用的是来自运行 java 代码的服务器的时间还是来自运行数据库的服务器的时间? 最佳答案 HQL 查询被翻译成 SQL 查询,SQL 查询由数据
我有一个 Hibernate HQL 问题。 我想将子查询编写为派生表(出于性能原因)。 可以在 HQL 中做到这一点吗? 例子: FROM Customer WHERE country.id in
我有三个表 A B 和 C。现在我想在 HQL 中执行这个 sql 查询: select * from A as a left join B as b on a.id = b.id left join
我是 Hive 的新手,想知道如何直接从 .hql 文件执行 hive 命令。 最佳答案 如 @rajshukla4696 所述,hive -f filename.hql 或 beeline -f f
出于各种原因,我正在尝试编写一个部分动态的 HQL 查询,而不求助于 Criteria API。我想知道是否有一种简单的方法可以使用 HQL 表达式来短路 where 限制。例如,这是工作正常的原始查
我正在自学 hibernate ,并且很困惑为什么我不能只编写简单的 SQL 查询。 我发现它比普通 SQL(我习惯的)使用起来更困惑 PLUS:我发现 NetBeans HQL 编辑器非常烦人,对我
非常感谢您帮助将以下 SQL 语句转换为有效的 HQL 语句。我尝试了几个小时但没有成功: SELECT * FROM master as m left outer join (select * fr
我有一个 HQL 查询: query = select item.itemNumber from items item where item.stock>0 and item.price it = q
我在以下代码段中遇到错误 using (var session = Database.OpenSession()) { var q = from x in session.Query()
我正在使用以下 C# 代码: public IList GetAllByExpression(Expression> expression, int startIndex, int count, Fu
我有 HQL,我试图在其中获取没有分类的工件(当 Activity 为 0 时) artifacts = Artifact.findAll("FROM Artifact WHERE id NOT IN
在 JPQL 中,我可以通过以下方式检索实体: query = entityManager.createQuery("select c from Category c"); List categori
我正在尝试使用 HQL 查询更新记录,但我收到了 CastException。如果有人可以帮助我,我将不胜感激。我已经在网上查了一段时间,但我找不到这方面的任何信息。如果您有关于此异常的更多信息,请告
我正在尝试在 JPA 中执行一个 select 语句,这会抛出上述错误。代码是: TypedQuery typedQuery = null; String query = ""; List list
我有问题要执行一个更新 HQL 查询。 我想编辑保存在配置文件实体中的值,但没有运气。 我的实体如下所示 @Entity @Table(name = "users", catalog = "testd
如何设置此 hql 查询的限制?当我在查询中添加 limit 关键字时,会引发错误。 @Query("from voucher v where v.voucherType.typeDescript
假设有两个表,A[a_id, b_id]和 B[b_id,c] . 我需要执行表单 "From A a ORDER BY a.b.c" 的 HQL 查询, 而 b在类 A 中可以为空. 但是,该查询仅
是否可以在 HQL 中运行与此类似的查询而无需指定所有列名。 select med, MAX(med.PrescriptionLines.Prescription.PrescriptionDate)
我是一名优秀的程序员,十分优秀!