-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Query Problem: relation "xyz" does not exist
PostPosted: Thu Jun 09, 2005 10:08 am 
Newbie

Joined: Thu Jun 09, 2005 9:53 am
Posts: 6
I have a table in Postgres as follows:
Code:
CREATE TABLE "DrugName"
(
  "drugNameID" int8 NOT NULL DEFAULT nextval('public."DrugName_drugNameID_seq"'::text),
  "drugName" varchar(100) NOT NULL,
  CONSTRAINT "DrugName_PK1" PRIMARY KEY ("drugNameID")
)
WITHOUT OIDS;
ALTER TABLE "DrugName" OWNER TO postgres;


And a DrugName hibernate java class as noted at the bottom of this post.
When I execute the following code:
Code:
Transaction tx = session.beginTransaction();
Criteria crit = session.createCriteria(DrugName.class);
List allRows = crit.list();


I get the following error. Help?

Code:
(cfg.Environment                     460 ) Hibernate 3.0
(cfg.Environment                     478 ) loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.postgresql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider, hibernate.max_fetch_depth=1, hibernate.cache.use_query_cache=true, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, hibernate.connection.username=postgres, hibernate.connection.url=jdbc:postgresql://localhost/test2, hibernate.show_sql=true, hibernate.connection.password=****}
(cfg.Environment                     506 ) using CGLIB reflection optimizer
(cfg.Environment                     536 ) using JDK 1.4 java.sql.Timestamp handling
(cfg.Configuration                   460 ) Mapping resource: com/test/model/testimport/DrugName.hbm.xml
(cfg.HbmBinder                       258 ) Mapping class: com.test.model.testimport.DrugName -> DrugName
(cfg.Configuration                   460 ) Mapping resource: com/test/model/testimport/DrugAssay.hbm.xml
(cfg.HbmBinder                       258 ) Mapping class: com.test.model.testimport.DrugAssay -> DrugAssay
(cfg.Configuration                   460 ) Mapping resource: com/test/model/testimport/DrugTestOrder.hbm.xml
(cfg.HbmBinder                       258 ) Mapping class: com.test.model.testimport.DrugTestOrder -> DrugTestOrder
(cfg.Configuration                   851 ) processing extends queue
(cfg.Configuration                   855 ) processing collection mappings
(cfg.Configuration                   864 ) processing association property references
(cfg.Configuration                   893 ) processing foreign key constraints
(dialect.Dialect                     91  ) Using dialect: org.hibernate.dialect.PostgreSQLDialect
(cfg.SettingsFactory                 87  ) Maximum outer join fetch depth: 1
(cfg.SettingsFactory                 90  ) Default batch fetch size: 1
(cfg.SettingsFactory                 94  ) Generate SQL with comments: disabled
(cfg.SettingsFactory                 98  ) Order SQL updates by primary key: disabled
(cfg.SettingsFactory                 273 ) Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
(ast.ASTQueryTranslatorFactory       21  ) Using ASTQueryTranslatorFactory
(cfg.SettingsFactory                 106 ) Query language substitutions: {}
(connection.DriverManagerConnectionProvider 41  ) Using Hibernate built-in connection pool (not for production use!)
(connection.DriverManagerConnectionProvider 42  ) Hibernate connection pool size: 20
(connection.DriverManagerConnectionProvider 45  ) autocommit mode: false
(connection.DriverManagerConnectionProvider 80  ) using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost/test2
(connection.DriverManagerConnectionProvider 86  ) connection properties: {user=postgres, password=****}
(cfg.SettingsFactory                 148 ) JDBC batch size: 15
(cfg.SettingsFactory                 151 ) JDBC batch updates for versioned data: disabled
(cfg.SettingsFactory                 156 ) Scrollable result sets: enabled
(cfg.SettingsFactory                 164 ) JDBC3 getGeneratedKeys(): disabled
(transaction.TransactionFactoryFactory 31  ) Using default transaction strategy (direct JDBC transactions)
(transaction.TransactionManagerLookupFactory 33  ) No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
(cfg.SettingsFactory                 176 ) Automatic flush during beforeCompletion(): disabled
(cfg.SettingsFactory                 179 ) Automatic session close at end of transaction: disabled
(cfg.SettingsFactory                 260 ) Cache provider: org.hibernate.cache.EhCacheProvider
(cfg.SettingsFactory                 187 ) Second-level cache: enabled
(cfg.SettingsFactory                 192 ) Optimize cache for minimal puts: disabled
(cfg.SettingsFactory                 199 ) Structured second-level cache entries: enabled
(cfg.SettingsFactory                 203 ) Query cache: enabled
(cfg.SettingsFactory                 247 ) Query cache factory: org.hibernate.cache.StandardQueryCacheFactory
(cfg.SettingsFactory                 210 ) Echoing all SQL to stdout
(cfg.SettingsFactory                 214 ) Statistics: disabled
(cfg.SettingsFactory                 218 ) Deleted entity synthetic identifier rollback: disabled
(cfg.SettingsFactory                 232 ) Default entity-mode: pojo
(impl.SessionFactoryImpl             140 ) building session factory
(config.Configurator                 126 ) No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/eclipse/ims-workspace/TestImport/buildoutput/dist/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
(impl.SessionFactoryObjectFactory    82  ) Not binding factory to JNDI, no JNDI name configured
(cache.UpdateTimestampsCache         43  ) starting update timestamps cache at region: org.hibernate.cache.UpdateTimestampsCache
(cache.EhCacheProvider               97  ) Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.
(cache.StandardQueryCache            50  ) starting query cache at region: org.hibernate.cache.StandardQueryCache
(cache.EhCacheProvider               97  ) Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.
(impl.SessionFactoryImpl             366 ) Checking 0 named queries
Hibernate: select this_.drugNameID as drugNameID0_, this_.drugName as drugName0_0_ from DrugName this_
(util.JDBCExceptionReporter          57  ) SQL Error: 0, SQLState: 42P01
(util.JDBCExceptionReporter          58  ) ERROR: relation "drugname" does not exist
Caught exception: could not execute query


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

Here's the DrugName.xbm.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
    <class
        name="com.test.model.testimport.DrugName"
        table="DrugName"
    >

        <id
            name="drugNameID"
            column="drugNameID"
            type="java.lang.Long"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-DrugName.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

            <property
                name="drugName"
                type="java.lang.String"
                    update="true"
                    insert="true"
            column="drugName"
            length="100"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-DrugName.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


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

Here's the DrugName.java file:
Code:
package com.test.model.testimport;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.test.model.common.BasePersistentDO;

/**
* This persistent class represents each individual drug name
* @hibernate.class table="DrugName"
*/
public class DrugName extends BasePersistentDO {
  private Long    drugNameID;
  private String  drugName;

  /**
   * Default Constructor
   */
  public DrugName() {
  }

  /**
   * Explicit constructor
   * @param drugNameID the ID associated with the drug name
   * @param drugName the name of the drug
   */
  public DrugName(String drugName) {
    this.drugName   = drugName;
  }

  /**
   * Gets the id of the drug name
   * @return the drug name ID
   * @hibernate.id generator-class="native"
   */
  public Long getDrugNameID() {
     return drugNameID;
  }

  /**
   * Sets the id of the drug name
   * @param drugNameID the id of the drug name
   */
  public void setDrugNameID(Long drugNameID) {
    this.drugNameID = drugNameID;
  }

  /**
   * Gets the name of the drug
   * @return the drug name
   * @hibernate.property length="100"
   */
  public String getDrugName() {
     return drugName;
  }

  /**
   * Sets the name of the drug
   * @param drugName the drug name
   */
  public void setDrugName(String drugName) {
    this.drugName = drugName;
  }

  public boolean equals(Object other) {
    if (this == other) {
      return true;
    }
    if (!(other instanceof DrugName)) {
      return false;
    }
    DrugName otherDrugName = (DrugName) other;
    EqualsBuilder eq = new EqualsBuilder().appendSuper(super.equals(other)).append(getDrugNameID(),
               otherDrugName.getDrugNameID());
      return eq.isEquals();
  }

  public int hashCode() {
    return new HashCodeBuilder(getMultiplierPrime(this), getNonZeroOddPrime(this)).append(getId()).append(getDrugNameID())
              .toHashCode();
  }
}


Top
 Profile  
 
 Post subject: Re: Query Problem: relation "xyz" does not exist
PostPosted: Thu Jun 09, 2005 10:18 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
youraveragejoe wrote:
I have a table in Postgres as follows:
Code:
CREATE TABLE "DrugName"
(
  "drugNameID" int8 NOT NULL DEFAULT nextval('public."DrugName_drugNameID_seq"'::text),
  "drugName" varchar(100) NOT NULL,
  CONSTRAINT "DrugName_PK1" PRIMARY KEY ("drugNameID")
)
WITHOUT OIDS;
ALTER TABLE "DrugName" OWNER TO postgres;


And a DrugName hibernate java class as noted at the bottom of this post.
When I execute the following code:
Code:
Transaction tx = session.beginTransaction();
Criteria crit = session.createCriteria(DrugName.class);
List allRows = crit.list();


I get the following error. Help?

....
....


The error message indicates that the Table "drugname" doesn't exist. I would make sure that the table has been created in the correct database and schema as those indicated in your mapping files.


Top
 Profile  
 
 Post subject: Re: Query Problem: relation "xyz" does not exist
PostPosted: Thu Jun 09, 2005 10:32 am 
Newbie

Joined: Thu Jun 09, 2005 9:53 am
Posts: 6
pksiv wrote:
The error message indicates that the Table "drugname" doesn't exist. I would make sure that the table has been created in the correct database and schema as those indicated in your mapping files.


The table "drugname" does not exist, but the "DrugName" table does exist. I do not use "drugname" anywhere in my code, but I do use "DrugName". Does Hibernate not allow for capital letters in table names?


Top
 Profile  
 
 Post subject: Re: Query Problem: relation "xyz" does not exist
PostPosted: Thu Jun 09, 2005 10:36 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
youraveragejoe wrote:
pksiv wrote:
The error message indicates that the Table "drugname" doesn't exist. I would make sure that the table has been created in the correct database and schema as those indicated in your mapping files.


The table "drugname" does not exist, but the "DrugName" table does exist. I do not use "drugname" anywhere in my code, but I do use "DrugName". Does Hibernate not allow for capital letters in table names?


I've never seen a problem with Hibernate and capitalization but I don't use Postgre.... so I'm not sure. When not using Hibernate, does Postgre care about capitalization ?


Top
 Profile  
 
 Post subject: Re: Query Problem: relation "xyz" does not exist
PostPosted: Thu Jun 09, 2005 11:21 am 
Newbie

Joined: Thu Jun 09, 2005 9:53 am
Posts: 6
pksiv wrote:
youraveragejoe wrote:
pksiv wrote:
The error message indicates that the Table "drugname" doesn't exist. I would make sure that the table has been created in the correct database and schema as those indicated in your mapping files.


The table "drugname" does not exist, but the "DrugName" table does exist. I do not use "drugname" anywhere in my code, but I do use "DrugName". Does Hibernate not allow for capital letters in table names?


I've never seen a problem with Hibernate and capitalization but I don't use Postgre.... so I'm not sure. When not using Hibernate, does Postgre care about capitalization ?


The solution at the bottom of thread below gets me past this problem. Like the user posted, I don't know if this is the correct solution.

http://forum.hibernate.org/viewtopic.php?t=941719


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.