0 Replies Latest reply on Oct 28, 2014 11:50 PM by erebos1337

    Database Table not found

    erebos1337

      Hey there,

      I'm just starting to learn programming with Java EE7

      and I have a problem with the database connection.

      I have installed Wildfly 8.1.0 Final and JBoss Tools Plugin for Eclipse,

      Eclipse Mars on Windows 7 64 Bit.

       

      If I do a GET Request I get the following error:

      04:29:42,575 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-6) SQL Error: 42102, SQLState: 42S02

      04:29:42,590 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-6) Tabelle "CHICKEN" nicht gefunden

      Table "CHICKEN" not found; SQL statement:

      select chicken0_.id as id1_0_, chicken0_.age as age2_0_, chicken0_.name as name3_0_ from Chicken chicken0_ [42102-173]

      04:29:42,590 ERROR [org.jboss.as.ejb3.invocation] (default task-6) JBAS014134: EJB Invocation failed on component ChickenService for method public java.util.List com.erebos.firsteeapp.business.chickens.boundary.ChickenService.getAllChickens(): javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not prepare statement

       

      If I do a POST Request I get the following error:

      04:31:55,724 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-7) SQL Error: 90036, SQLState: 90036

      04:31:55,724 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-7) Sequenz "HIBERNATE_SEQUENCE" nicht gefunden

      Sequence "HIBERNATE_SEQUENCE" not found; SQL statement:

      call next value for hibernate_sequence [90036-173]

      04:31:55,724 ERROR [org.jboss.as.ejb3.invocation] (default task-7) JBAS014134: EJB Invocation failed on component ChickenService for method public void com.erebos.firsteeapp.business.chickens.boundary.ChickenService.save(com.erebos.firsteeapp.business.chickens.entity.Chicken): javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not prepare statement

       

      The request delegetions seem to work, the errors occur when the requests are processed by the EntityManager.

      java_ee_error_save.png

       

      My persistence.xml looks like this:

      <?xml version="1.0" encoding="UTF-8"?>

      <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence

      http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"

      version="2.1">

        <persistence-unit name="prod" transaction-type="JTA">

        <properties>

        <property name="java.persistence.schema-generation.database.action" value="DROP-AND-CREATE"/>

        </properties>

        </persistence-unit>

      </persistence>

       

      And thats how the Chicken Entity looks like:

      @XmlRootElement

      @Entity

      @XmlAccessorType(XmlAccessType.FIELD)

      @NamedQuery(name="all",query="SELECT c FROM Chicken c")

      public class Chicken {

        @Id

        @GeneratedValue

        private long id;

        private String name;

        private int age;

       

        public Chicken(String name, int age) {

        this.name = name;

        this.age = age;

        }

       

       

        public Chicken() {

        }

      }

       

      The Chicken Table was not found,

      so I guess the database works,

      hence it wouldn't know if there is a table or not,

      but most likely throw an error that the db doesn't work.

      I guess the table is not being created automatically

      by JPA or the EntityManager and that causes the error.

      But maybe I'm totally wrong.

       

      I have no idea how to fix this, thats why I'm asking you for help.

      If you require more information, I'm willing to give it to you.

       

      Thanks for your help.