Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't create jpa tables in eclipse

I had a working project in eclipse which created a JPA table from entity to mysql database (still learning). Unfortunately it made the table in the wrong database as I wanted there to be 'test' and 'production' databases. Somehow it got the details for the 'production' db, even that it looked like the selected database connection was for the test. I tampered with the project a bit and made it to connect with right connection object for certain (test). I can ping the db in eclipse (both dbs) and see the db in the Data Source Explorer. But now I can not create the table(s) for the project by right clicking on it and selecting 'JPA 'Tools' > 'Generate Tables from Entities'. The creation starts and finishes with no errors, like everything works, yet I see no tables in either of the databases. (In eclipse Database explorer or from command line). The persistence.xml should be fine as it already created that one table before.

The only error is for the Entity class as it says for the Entity annotation "Table xxx cannot be resolved". And as I see, it's coming from the table not being created.

Here's the persistence.xml just in case. http://pastebin.com/djPZei90

The project is also a Maven project and it uses SVN. The dependencies were successfully loaded by the maven for the eclipse/project and there is no complications with the SVN.

Because of Maven there are 2 persistence.xml files (only the login credentials and the database name changes), for production and test. It could be that the db-connection was checked and loaded from the wrong file at the 1st place. (just guessing)

Also I tried to create the script.sql when generating the table(s). I found the file but it was completely empty.

Anyway the problem is now that I can't create the tables anywhere. I am totally puzzled by this. Any hints where I should look to fix this?

like image 689
Ville Myrskyneva Avatar asked Oct 22 '25 10:10

Ville Myrskyneva


2 Answers

Chris had it right, even that I didn't understand the answer correctly at the first reading. I tried with the other provider, but I may had modified the wrong file by accident (2 'persistence.xml' files as it's a maven project), or there may have been some other reason I failed to spot. I was given a hint earlier, that I should use the given provider (in persitence.xml). Causing that I didn't pay too much attention to it after all. Since using eclipselink, the provider has to be indeed:

    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

Thanks again Chris, even that I failed at the first attempt and had to spend several more hours on resolving this.

like image 185
Ville Myrskyneva Avatar answered Oct 25 '25 00:10

Ville Myrskyneva


Could you solve the problem? Unfortunately I have stumbled on the same rare issue, which totally makes no sense. The JPA Tools just doesn't add the mapping classes for whatever reason, although it writes them into the persistence.xml.

Previous week everything worked flawlessly but now everything is f**. I even created a new independent project in different workspace but it happens the same bug. Obviously it's an eclipse/plugin bug, otherwise I can't explain it. Working with eclipse 4.2.0. I am not happy.

Edit: After removing Dali Tools, JPA Configurator, Seam 3 Plugin creating entities seems to work again. Don't know why, most likely a conflict, but it still doesn't explain why it happened now and not 1 month ago. I didn't change my eclipse install at all since then...

like image 36
Malvin Avatar answered Oct 25 '25 00:10

Malvin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!