title: Setup JPA Console in Intellij using Spring
body: <p>I'm trying to get the JPA console working in Intellij. I have added JPA to the project under facets. However, IDE is asking for a persistence.xml. I'm using Annotated Spring and don't have any direct mapping files. Anyone configured this before, and can help me? Thanks</p>
  
  <p>Further information:</p>
  
  <p>Without adding JavaEE stuff - I don't need this.
  File->Project Structure - Under modules: add JPA to a single module. Do not add persistence.xml or orm.xml</p>
  
  <p>Under facets: Add JPA. Leave XML config blank. Leave JPA Provider blank</p>
  
  <p>View -> Tool windows -> Persistence</p>
  
  <p>You will see the module name and the EntityManager as configured under your SpringContext.xml. On my system I have these properties referenced in this SpringContext.xml</p>
  
  <pre><code># jdbc.X
  jdbc.driverClassName=org.postgresql.Driver
  jdbc.url=jdbc:postgresql:///someThing
  jdbc.user=postgres
  jdbc.pass=postgres
  
  # hibernate.X
  hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect
  hibernate.show_sql=false
  hibernate.hbm2ddl.auto=create
  </code></pre>
  
  <p>I then select in my Persistence window (in which I can now see all entities) - click console button. Select JPA console. This will get me the error outlined here {yes, I'm using Postgres}</p>
  
  <p><a href="https://intellij-support.jetbrains.com/hc/en-us/community/posts/206186929-JPA-Console-without-persistence-xml" rel="nofollow noreferrer">https://intellij-support.jetbrains.com/hc/en-us/community/posts/206186929-JPA-Console-without-persistence-xml</a></p>
  
  <p>Note the two "TTs-" PostgreSQL9Dialectt</p>
  
  <p>Further further information:</p>
  
  <p>Wierd. If I move the dialect into the actual xml config</p>
  
  <pre><code> &lt;property name="jpaProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.hbm2ddl.auto"&gt;${hibernate.hbm2ddl.auto}&lt;/prop&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.PostgreSQL9Dialect&lt;/prop&gt;
             &lt;!--&lt;prop key="hibernate.enable_lazy_load_no_trans"&gt;true&lt;/prop&gt;--&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  
  [2017-01-04 13:03:46] java.lang.IllegalStateException: Transaction already active
  at org.hibernate.engine.transaction.internal.TransactionImpl.begin(TransactionImpl.java:52)
  at com.intellij.jpa.remote.impl.RemoteQueryImpl$1.getResultList(RemoteQueryImpl.java:92)
  at com.intellij.jpa.remote.impl.QueryResultImpl.ensureInitialized(QueryResultImpl.java:113)
  at com.intellij.jpa.remote.impl.QueryResultImpl.getColumnInfos(QueryResultImpl.java:30)
  at com.intellij.jpa.remote.impl.RemoteQueryResultImpl.getColumnInfos(RemoteQueryResultImpl.java:79)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  </code></pre>