0

I am trying to resolve this problem since 3 days, I cannot solve it. I read about, that IntelliJ is mixing up something. I found that thread and similar answers in other threads, and tried to to exactly the same, but it did not work: Cannot resolve column 'USERNAME' less

My Persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
    <persistence-unit name="NewPersistenceUnit">
        <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
        <class>Book</class>
        <properties>
            <property name="hibernate.hbm2ddl.auto" value="create-drop"></property>
            <property name="hibernate.show_sql" value="true"></property>
        </properties>
    </persistence-unit>
</persistence>

My class Book where I want to set the name. The Table "Book" cannot be resolved.

 @Entity    
 @Table(name = "BOOK")
        public class Book implements Serializable{

            @Id
            private int id;

        }
Community
  • 1
  • 1
csnewb
  • 1,190
  • 2
  • 19
  • 37

1 Answers1

1

In addition to what the answer you posted, in the persistence tool window (view -> tool windows -> persistence), you should see persistence.xml, right click and select "assign data source" and assign your configured datasource.

More info here: My Favorited Question

Community
  • 1
  • 1
crumbug
  • 428
  • 3
  • 13
  • How can I check, if my Data Source is correctly configured? I remember, that it once worked, but I have never configured my Data Source. Suddenly, I don't know how, it stopped working. – csnewb Apr 28 '16 at 21:19
  • click on view -> tool windows -> database, right click on your database -> properties. Then there will be a "Test Connection" button. If it is configured properly, it should say "Connection Successful", if it's not configured properly it will throw an exception. – crumbug Apr 28 '16 at 21:37
  • Connection successful... I think my hibernate is not integrated the proper way, but I set up everything with hibernate. The weird think is, that if i put `org.hibernate.jpa.HibernatePersistenceProvider` to my `persistence.xml`, it tells me that `jpa.HibernatePersistenceProvider` cannot be resolved. – csnewb Apr 28 '16 at 21:45
  • another thing to try that I just noticed is, you are just using "Book" in persistence.xml You need to use the fully qualified name, like com.mycompany.Book – crumbug Apr 28 '16 at 21:53
  • I don't have a package name, but I also tried to create a package name and do it like you have told. No changes... – csnewb Apr 28 '16 at 21:58