English 中文(简体)
PSQLException: ERROR: relation “TABLE_NAME”并不存在
原标题:PSQLException: ERROR: relation "TABLE_NAME" does not exist

我正试图以邮政局8.4.2 DB为生。 每当我试图实施一个简单的java法典时,即:

List<User> users = service.findAllUsers();

我有以下错误:

PSQLException: ERROR: relation "TABLE_NAME" does not exist

自2006年以来 我有选择。 • 显示“sql”方案是真实的,我可以看到,解放者正在试图管理以下指挥系统:

    select this_.USERNAME as USERNAME0_0_, this_.PASSWORD as PASSWORD0_0_ 
from "TABLE_NAME" this_

在现实中,它至少应该像:

    select this_."USERNAME" as USERNAME0_0_, this_."PASSWORD" as PASSWORD0_0_ 
from "SCHEMA_NAME"."TABLE_NAME" as this_

是否有任何人知道,我需要做些什么改变才能为PogreSQL制定正确的标准?

我在申请中建立了必要的邮政数据来源。

<!-- Use Spring annotations -->
 <context:annotation-config /> 
 <!-- postgreSQL datasource -->
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
  destroy-method="close">
  <property name="driverClassName" value="org.postgresql.Driver" />
  <property name="url"
   value="jdbc:postgresql://localhost/DB_NAME:5432/SCHEMA_NAME" />
  <property name="username" value="postgres" />
  <property name="password" value="password" />
  <property name="defaultAutoCommit" value="false" />
 </bean>

在同一个档案中,我设立了“SQL”透视厂:

<!-- Hibernate session factory -->
 <bean id="sessionFactory"   class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
  <property name="dataSource" ref="dataSource" />
  <property name="annotatedClasses">
   <list>
    <value>com.myPackage.dbEntities.domain.User</value>
   </list>
  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
   </props>
  </property>
 </bean>
 <!-- setup transaction manager -->
 <bean id="transactionManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
   <ref bean="sessionFactory" />
  </property>
 </bean>

最后,我对表上域类别进行测绘的方式是:

    @Entity
@Table(name = "`TABLE_NAME`")
public class User {
@Id
@Column(name = "USERNAME")
private String username;

Has anyone encountered a similar error?. Any help in solving this issue will be much appreciated. Please note that question is different to post Cannot simply use PostgreSQL table name (”relation does not exist”)

长期职位的候选人。

最佳回答
问题回答

如果你使用泉水箱,在配置中设定缺省表:

spring.jpa.properties.hibernate.default_schema: my_schema

保证在质询中填表:

@Query(value = "SELECT user_name FROM my_schema.users", nativeQuery = true)
List<String> findAllNames();

看看邮政总局的司机文件,似乎不支持你在连接图末添加插图。 你们是否确信应该工作?

一项工作是将搜索——放在数据库中,以包括你的图象,但如果你在多个图象上有相同的表格,这显然会失败。

我不知道,如果能够让它了解一个图象的话,那就够了。

由于使用了一栏定义,因此正在发现这一错误。

issue @Column(name = "user_id", nullable = false, unique = true, columnDefinition ="user unique ID" )

solved @Column(name = "user_id", nullable = false, unique = true)

增 编

我的问询表明:

@Query(value = "SELECT tbl.* FROM my_schema.my_table tbl", nativeQuery = true)

浏览器有某些参考文件“tbl”,在盘点中使用。

在我的案例中,我在上封信中用图谋名称,我把图谋名称改为下几封信。

在实体中,我对地图作了如下改动:

from @Table(name="table_name", schema = "SCHEMA") to @Table(name="table_name", schema = "schema")





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签