带有persistence.xml的Intellij JPA控制台

jer*_*erg 1 spring jpa intellij-idea

我正在使用Intellij 13+设置一个不含xml的持久性JPA/Hibernate 4 +/Spring 3+.当我尝试在jpa控制台中执行查询时,出现以下错误:

javax.persistence.PersistenceException: Unable to build entity manager factory
java.lang.RuntimeException: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.dialect.PostgreSQL9Dialectt.PostgreSQL9Dialect] as strategy [org.hibernate.dialect.Dialect]
Run Code Online (Sandbox Code Playgroud)

使用默认的postgres方言,我得到相同的错误.知道发生了什么事吗?

配置提取:

<bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="com.wikiz.service.model.rep" />
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
    </property>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
            <prop key="jadira.usertype.autoRegisterUserTypes">true</prop>
            <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
        </props>
    </property>
</bean>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${db.driver}"/>
    <property name="url" value="${db.url}"/>
    <property name="username" value="${db.user}"/>
    <property name="password" value="${db.pass}"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

和变量:

hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.hbm2ddl.auto=create
Run Code Online (Sandbox Code Playgroud)

zpo*_*kas 8

好的,这是.我不是100%确定这是否有助于您的情况,但我认为这是您需要做的:从数据库选项卡(通常在右侧)添加到数据库的jdbc连接 将jdbc连接添加到数据库


然后将hibernate facet添加到模块中转到模块(alt+ ctrl+ shift+ s)然后添加它: 在此输入图像描述
现在您已经启用了左侧(通常)的持久性选项卡,您可以为您的数据源分配数据源

现在添加hibernate配置,但你必须添加hibernate的xml文件.我还没有尝试添加spring应用程序上下文而不是hibernate.cfg.xml.也许它会起作用......
在此输入图像描述


现在,您已为intellij启用了presistance配置,您可以为其分配数据源.
在此输入图像描述
选择您想要的数据源,您将能够将JPA控制台与您的jpa POJO和HSQL一起使用
在此输入图像描述