4 Replies Latest reply on Feb 11, 2015 8:54 AM by rastin rastini

    hibernate dont find schema

    rastin rastini Newbie

      hi all

      have wildfly 8.2.0 .

      have an postgres db and an schema named 'authorization_central'.

      entity mode is:

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

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

      @XmlRootElement(name = "users")

      @Entity

      @Table(name = "tblusers", schema = "authorization_central")

      public class User implements Serializable {

       

          private static final long serialVersionUID = 1L;

          @Id

          @GeneratedValue(strategy = GenerationType.AUTO)

          private Long id;

          private String userName;

          private String password;

       

          @XmlElement

          public String getUserName() {

              return userName;

          }

       

          public void setUserName(String userName) {

              this.userName = userName;

          }

       

          @XmlElement

          public String getPassword() {

              return password;

          }

       

          public void setPassword(String password) {

              this.password = password;

          }

       

          @XmlElement

          public Long getId() {

              return id;

          }

       

          public void setId(Long id) {

              this.id = id;

          }

       

          @Override

          public int hashCode() {

              int hash = 0;

              hash += (id != null ? id.hashCode() : 0);

              return hash;

          }

       

          @Override

          public boolean equals(Object object) {

              // TODO: Warning - this method won't work in the case the id fields are not set

              if (!(object instanceof User)) {

                  return false;

              }

              User other = (User) object;

              if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {

                  return false;

              }

              return true;

          }

       

          @Override

          public String toString() {

              return "domain.models.User[ id=" + id + " ]";

          }

       

      }

       

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

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

       

       

      persistence.xml is

       

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

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

       

       

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

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

          <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

          <class>domain.models.User</class>

          <properties>

            <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>

            <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://127.0.0.1:5432/postgres"/>

            <property name="javax.persistence.jdbc.user" value="postgres"/>

            <property name="javax.persistence.jdbc.password" value="1234"/>

            <!--<property name="javax.persistence.jdbc.user" value="rastin"/>-->

            <!--<property name="javax.persistence.jdbc.password" value="bt_Ummah"/>-->

            <!--<property name="javax.persistence.schema-generation.database.action" value="create"/>-->

            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>

            <property name="hibernate.show_sql" value="true"/>

            <property name="hibernate.hbm2ddl.auto" value="create-drop"/>

          </properties>

        </persistence-unit>

      </persistence>

       

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

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

       

       

      my problem is in this class:

       

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

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

       

      @Transactional

      public class EntityDao {

       

          @PersistenceContext(name = "UserPersistenceUnit")

          EntityManager entityManager;

       

          public void add(Object t) {

              try {

                  System.out.println("start adding4.");

                  if (entityManager == null) {

                      System.out.println("entity manager is null.");

                      entityManager = Persistence.

                              createEntityManagerFactory("UserPersistenceUnit").

                              createEntityManager();

                      if (entityManager != null) {

                          System.out.println("entity manager created.");

                      }

                  }

      //            entityManager.getTransaction().begin();

                  entityManager.persist(t);

      //            entityManager.getTransaction().commit();

              } catch (Exception e) {

                  e.printStackTrace();

                  System.out.println(e.getMessage());

              }

          }

       

      }

       

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

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

       

       

       

      send me error:

      ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-7) Schema "AUTHORIZATION_CENTRAL" not found; SQL statement:

      insert into authorization_central.tblusers (password, userName, id) values (?, ?, ?) [90079-173]

       

      any one can help?

      thankful.