Intellij如何使用spring boot正确配置hql。 现在我得到持久性QL查询被错误检查
所以我试图使用hibernate和jpa的自定义查询
@Transactional public interface EstimateOptionsDao extends JpaRepository { @Query("from estimateOptions options inner join options.company company inner join company.user user where user.name = :userName\n") 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:
<!-- update -->
和弹簧配置如下:
spring.datasource.url=jdbc:mysql://localhost:3306/testdb spring.datasource.username=root spring.datasource.password=root spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
但是,如果我在intellij中使用持久性工具,请执行以下简单查询:
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: .....
你可以看到我有点迷失……这些设置有什么问题?
- 在
Project structure
设置(ctrl + alt + shift + s)中,选择Facets
和Add
。 - 选择
JPA
- 选择包含映射/带注释实体的模块
- 在
Modules
视图中,选择有问题的模块和下面的JPA
facet - 添加对描述符的引用(persistence.xml / orm.xml)
- 从下拉列表中选择您的JPA提供程序
然后,您的JPA查询应该针对您的entites进行validation。
- Spring源码套件spring3 + Hibernate4 + maven 3 + MySQL 5
- 我怎么能用Hibernate的“无法解析配置”错误?
- 表每子类inheritance关系:如何在不加载任何子类的情况下查询Parent类??? (hibernate)
- 事务性保存而不调用更新方法
- 在Hibernate中更改外键的生成名称
- 重写持久化实体的hashCode()和equals()方法的正确方法是什么?
- 如果没有活动事务,Spring Hibernate集成抛出getFlushMode无效
- ParameterizedType并创建一个通用的dao
- JPA spring boot内部join – with-clause引用了两个不同的from-clause元素错误