带有persistence.xml的Intellij JPA控制台 [英] Intellij JPA Console with persistence.xml

查看:336
本文介绍了带有persistence.xml的Intellij JPA控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm setting up a xml-free persistence JPA/Hibernate 4+/Spring 3+ using Intellij 13+. When I try to execute a query in the jpa console, I get the following error:

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]

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

With the default postgres dialect, I get the same error. Any idea what's going on?

配置摘录:

<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>

变量:

hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.hbm2ddl.auto=create


推荐答案

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

Ok here it is. I am not 100% sure if this helps your case but I think this is what you need to do: Add a jdbc connection to your database from the database tab (usually to your right)

< br>
然后将hibernate facet添加到模块
转到模块( alt + ctrl + shift + < kbd> s )然后添加它:



现在你已经启用了左边的persistance选项卡(通常),你可以为你的


Then add the hibernate facet to your module Go to modules (alt+ctrl+shift+s) then add it:
Now you have enabled the persistance tab on your left (usually) and you can assign a datasource to your

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

Now add the hibernate configuration but you have to add the xml file of hibernate. I haven't tried it with just adding the spring application context instead of hibernate.cfg.xml. Maybe it will work...



现在你已经启用了intellij的预先配置,你可以为它分配一个数据源。




选择您想要的数据源,您将能够将JPA控制台与您一起使用jpa POJO和HSQL


Now you have enable the presistance configuration for intellij and you can assign a datasource to it.

Select that datasource that you want and you will be able to use the JPA console with your jpa POJOs and HSQLs

这篇关于带有persistence.xml的Intellij JPA控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆