Intellij如何使用Spring Boot正确配置hql现在我得到持久性QL查询已进行错误检查

【字号: 日期:2024-04-02浏览:46作者:雯心
(adsbygoogle = window.adsbygoogle || []).push({}); 如何解决Intellij如何使用Spring Boot正确配置hql现在我得到持久性QL查询已进行错误检查?在Project structure设置(ctrl + alt + shift + s)中,选择Facets和Add。选择 JPA选择包含您的映射/注释实体的模块在Modules视图中,选择有问题的模块和JPA下面的构面添加对描述符的引用(persistence.xml / orm.xml)从下拉列表中选择您的JPA提供商

然后,应针对您的实体验证您的JPA查询。

解决方法

所以我试图通过hibernate和jpa使用自定义查询

@Transactionalpublic interface EstimateOptionsDao extends JpaRepository<EstimateOptions,Integer> { @Query('from estimateOptions options inner join options.company company inner join company.user user where user.name = :userNamen') EstimateOptions EstimateOptions(String userName);}

但是,这EstimateOptions给了我以下错误:

Can’t resolve symbol ’EstimateOptions’ less... (Ctrl+F1) This inspection controls whether the Persistence QL Queries are error-checked

所以我发现了这篇文章为什么Hibernate查询在IntelliJ中有编译错误?。

所以我添加了一个方面来测试:

现在我有这样的hibernate.cfg.xml:

<?xml version=’1.0’ encoding=’utf-8’?><!DOCTYPE hibernate-configuration PUBLIC '-//Hibernate/Hibernate Configuration DTD//EN' 'http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd'><hibernate-configuration> <session-factory> <property name='connection.url'/> <property name='connection.driver_class'/> <property name='connection.username'/> <property name='connection.password'/> <!-- DB schema will be updated if needed --> <!-- <property name='hbm2ddl.auto'>update</property> --> </session-factory></hibernate-configuration>

和弹簧配置是这样的:

spring.datasource.url=jdbc:mysql://localhost:3306/testdbspring.datasource.username=rootspring.datasource.password=rootspring.datasource.driverClassName=com.mysql.jdbc.Driverspring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialectspring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy

但是,如果我使用intellij的Persistence Tool进行了如下简单查询:

hql>来自用户

它产生以下错误:

[2015-12-09 12:59:27] org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [][2015-12-09 12:59:27] java.lang.ClassNotFoundException: .....

如您所见,我有点迷路…这些设置有什么问题?

相关文章: