Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Intellij如何使用spring引导正确配置hql。现在我得到了持久性SQL查询的错误检查_Java_Spring_Hibernate_Jpa_Intellij Idea - Fatal编程技术网

Java Intellij如何使用spring引导正确配置hql。现在我得到了持久性SQL查询的错误检查

Java Intellij如何使用spring引导正确配置hql。现在我得到了持久性SQL查询的错误检查,java,spring,hibernate,jpa,intellij-idea,Java,Spring,Hibernate,Jpa,Intellij Idea,所以我尝试使用hibernate和jpa来使用自定义查询 @Transactional public interface EstimateOptionsDao extends JpaRepository<EstimateOptions, Integer> { @Query("from estimateOptions options inner join options.company company inner join company.user user where us

所以我尝试使用hibernate和jpa来使用自定义查询

@Transactional
public interface EstimateOptionsDao extends JpaRepository<EstimateOptions, Integer> {

    @Query("from estimateOptions options inner join options.company company inner join company.user user where user.name = :userName\n")
    EstimateOptions EstimateOptions(String userName);

}
所以我找到了这个帖子

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

现在我有了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>
但如果我使用intellij en中的持久性工具,请执行以下简单查询:

<?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>
hql>来自用户

它会产生以下错误:

Can't resolve symbol 'EstimateOptions' less... (Ctrl+F1) 
This inspection controls whether the Persistence QL Queries are error-checked
[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: 
.....
正如你所看到的,我有点迷路了。。。这些设置有什么问题

  • 项目结构
    设置(ctrl+alt+shift+s)中,选择
    Facets
    添加
  • 选择
    JPA
  • 选择包含映射/注释实体的模块
  • Modules
    视图中,选择有问题的模块和下面的
    JPA
    方面
  • 添加对描述符的引用(persistence.xml/orm.xml)
  • 从下拉列表中选择您的JPA提供商

  • 然后应该根据实体验证JPA查询

    谢谢,我一整天都在为这件事苦苦挣扎。但你真的救了我;)我已经在基于注释的配置中使用SpringMVC配置了hibernate。但是只有.xml格式的描述符可以添加到JPA方面。如何使用基于注释的hibernate配置执行上述过程?您没有任何xml文件,甚至没有一个说明在何处查找基于注释的配置的文件?JPA默认提供程序下拉列表如何?这里有相同的问题,如果您的项目中没有定义任何描述符或bean,则可能会出现这种情况(但让spring启动来完成工作)intelliJ不会对HQL查询执行验证