6 Replies Latest reply on Oct 16, 2014 3:52 PM by msalvatore

    Catalog "" cannot be resolved for table ""

    msalvatore

      Hello,

       

      I've seen a similar problem in forums from a couple years ago but it was never completely answered.

       

      I'm trying to generate Entities from Tables.  I've tried both with right-clicking the project and selecting JBoss Tools -> Generate Entities from Tables...  as well as by creating a Hibernate Code Generation Configuration.  Either way I get an error on line 8 of TestTable.java (below) of:  Catalog "testdb" cannot be resolved for table "test_db"

       

      If I'm missing any  necessary information I'd be happy to provide it.

       

      IDE: Eclipse Luna

      Project Name: testdb

      JBoss/Hibernate Tools: v4.3.1

      JDK: jdk1.7.0_67

      Target Runtime: JBoss 7.1 Runtime

      Facets:

           Dynamic Web Module  -> 3.0

           Java -> 1.7

           JavaScript -> 1.0

           JavaServer Faces -> 2.1

           JAX-RS -> 1.1

           JPA -> 2.1

                Platform: Hibernate (JPA 2.1)

                JPA Implementation:  Library Provided by Target Runtime

                Connection: testuser@testdb

       

      Connection: testuser@testdb

           Driver: MySQL JDBC Driver

           Database: testdb

           URL: jdbc:mysel://localhost:3306/testdb

           User: testuser

       

      persistence.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="2.1" 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"> 
        <persistence-unit name="testdb">
        </persistence-unit>
      </persistence>
      

          

      hibernate.properties
      hibernate.default_schema=testdb
      hibernate.default_catalog=testdb
      

       

      TestTable.java
      package com.company.model;
      
      // Generated Oct 15, 2014 1:25:32 PM by Hibernate Tools 4.3.1
      
      import *;
      
      @Entity
      @Table(name="test_table")
      public class TestDatum implements java.io.Serializable
      {
           private Integer id
           private String code;
           private String description;
           ...
      }
      

       

      Thanks,

       

      Mike

        • 1. Re: Catalog "" cannot be resolved for table ""
          maxandersen

          is there no stacktrace ?

           

          and are you sure you have both a schema and catalog named testdb in your mysql setup ?

          • 2. Re: Re: Catalog "" cannot be resolved for table ""
            msalvatore

            Max,

             

            It's not executing and there's nothing in the Eclipse logs so there's no stack trace.  This error just shows up during validation in Eclipse. (The properties of the error in the Markers view gives no extra information.)

             

            If I run the query: select * from information_schema.tables where table_schema="testdb" it tells me that TABLE_CATALOG='def'.

             

            No matter what value I set hibernate.default_schema to it simply updates the error message and complains about that schema not being found, even if I set it to 'def'.  Also, if I remove the hibernate.default_schema line from my properties it reverts back to 'testdb' as the catalog it is looking for.  The same occurs if I alter the code and explicitly name the catalog in the @Test parameters.

            • 3. Re: Re: Catalog "" cannot be resolved for table ""
              maxandersen

              I think you are bumping into Eclipse Dali validation bug when it comes to mysql and catalog handling.

               

              Can you show the full validation marker ? just right click and copy it and then paste content here.

              • 4. Re: Re: Catalog "" cannot be resolved for table ""
                msalvatore

                Is this what you mean?

                 

                DescriptionResourcePathLocationType
                Catalog "testdb" cannot be resolved for table "test_table"TestTable.java/testdb/src/main/java/com/company/modelline 14JPA Problem

                 

                Edited for spelling.

                • 5. Re: Re: Catalog "" cannot be resolved for table ""
                  maxandersen

                  yes.

                   

                  So you do not have the catalog listed in your java class ?

                   

                  if you do not, go into JPA Facet properties and define the connection to use and in here you can customize/override the default catalog/schema. See if that works?

                  • 6. Re: Re: Catalog "" cannot be resolved for table ""
                    msalvatore

                    The catalog isn't listed in the class but if I add one it just updates the error message.

                     

                    In the JPA settings, if I select to override the catalog, nothing is in the dropdown.  If I select to override the schema the expected value _is_ in the dropdown so it seems it's not getting any catalog names from the connection?