I'm trying to create simple EJB + JPA project in Eclipse (Indigo). I created new EJB project where:
I have problem when I'm trying to define entity: Table "Employee" cannot be resolved. I added @Table annotation with specified name parameter but this didn't work. My persistence.xml file:
<persistence-unit name="pu_name">
<jta-data-source>jdbc/baza1Postgres</jta-data-source>
</persistence-unit>
In glassfish I have defined JDBC Resource with name: "jdbc/baza1Postgres"
How "eclipse know" if my table exist? What else I should configure?
Found this solution to "Table xxx cannot be resolved" error:
In Eclipse, go to Window -> Preferences -> Validation, JPA Validator, turn off for Build.
Sometimes you’re developing an app along with a new database schema to go with it, but you get this:
Schema "null" cannot be resolved for table "XXXX".
This probably shouldn’t be on by default anyway; people are most likely going to build new apps from scratch than build new apps to fit old databases, and even if they do build from old, Eclipse’s JPA Tools has a build entities from tables function."
In Eclipse to make it happy I had to create the table via JPA Tools.
Right Click Project > JPA Tools > Generate Tables from Entities
I guess you could turn off validation too, but creating the table seems to make more sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With