Quantcast
Channel: JetBrains Developer Community : Thread List - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5661

How to generate Persistence units?

$
0
0

Hello,

 

I'm having a hibernate project setup issue. During project setup, I didn't select JEE persietence, but instead just told Intellij I was using Hibernate.

 

-------------------------------


Here's what I did:

 

(1) I created a regular Java Web project where I selected to include Hiberante and MySQL jars.

 

(2) I created a db connection to the database and confirmed it was "query-able" from the Intelilj project.

 

The Hibernate Config generated has the DB connection information, with user and password.

 

(3) I generated a Persistence mapping from the database in the Persistence tab of Intelij.

 

The entity class for zipcodes looks correctly generated.

 

(4) Then wrote a quick DAO:

 

public static void main(String[] args)
    {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("Zipcodes");

        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        tx.begin();

 

        // test get the zip code list...
        List zipCodes = (ArrayList) em.createQuery("SELECT from ZIPCODES");

 

        tx.commit();
        em.close();

 

// code compiles.

 

Yet, when I try to run this, I get this error: "Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager"

 

Didn't Intellij already generate this persistence info in step 3 above?

 

I looked into this error and it says I have to have a persietence.xml in the WEB-INF folder. However, Intellij didn't create either a persistence.xml or a WEB-INF folder in this project.

 

Thanks in advance for any help or suggestions.


-m


Viewing all articles
Browse latest Browse all 5661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>