Relation “xxxx” does not exist

Refresh

April 2019

Views

308 time

1

Can you tell me how to fix this exception from console?

org.postgresql.util.PSQLException: ERROR: relation "xxxx" does not exist

This exception is for some tables in my project, and I don't know why. Application works fine without any issues. I have in resources import script dml and tables are filled as well.

Here is my sample implementation table:

@Entity
@Table(name = "USERS")
public class User extends Abstract {

    @Column(name = "FIRST_NAME", nullable = false, length = 100)
    private String firstName;

    @Column(name = "LAST_NAME", nullable = false, length = 100)
    private String lastName;

    @Column(name = "EMAIL", nullable = false, length = 100)
    private String email;

    @Column(name = "PASSWORD", nullable = false, length = 60)
    private String password;

    @Column(name = "PHONE_NUMBER", nullable = false, length = 20)
    private String phoneNumber;

    @Column(name = "BIRTHDATE", nullable = false, columnDefinition = "TIMESTAMP")
    private LocalDateTime birthdate;

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(
            name = "USERS_CONTACTS",
            joinColumns = @JoinColumn(name = "USER_ID",
                    foreignKey = @ForeignKey(name = "FK__USERS__USERS__USER_ID")),
            inverseJoinColumns = @JoinColumn(name = "CONTACT_ID",
                    foreignKey = @ForeignKey(name = "FK__USERS__USERS__CONTACT_ID")))
    private List<User> contacts;

    // getters and setters
}

and abstract class:

@MappedSuperclass
public class Abstract {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", columnDefinition = "serial")
    private Long id;

    @Column(name = "CREATED_ON", nullable = false, columnDefinition = "TIMESTAMP")
    private LocalDateTime createdOn;
}

Here is full console log:

Hibernate: alter table users_contacts drop constraint FK__USERS__USERS__USER_ID
2018-01-22 15:57:32.177  WARN 28193 --- [           main] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.applyConstraintDropping(SchemaDropperImpl.java:331) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:230) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:112) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:144) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:313) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:889) [hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) [spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) [spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) [spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) [spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) [spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) [spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) [spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) [spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at sk.moe.zoya.ZoyaApplication.main(ZoyaApplication.java:10) [classes/:na]
Caused by: org.postgresql.util.PSQLException: ERROR: relation "users_contacts" does not exist
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:303) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
    at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:289) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:266) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:262) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114) ~[tomcat-jdbc-8.5.23.jar:na]
    at com.sun.proxy.$Proxy81.execute(Unknown Source) ~[na:na]
    at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-5.2.12.Final.jar:5.2.12.Final]
    ... 35 common frames omitted

Hibernate: drop table if exists feeds cascade
2018-01-22 15:57:32.178  WARN 28193 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
2018-01-22 15:57:32.178  WARN 28193 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : table "feeds" does not exist, skipping
Hibernate: drop table if exists messages cascade
2018-01-22 15:57:32.178  WARN 28193 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
2018-01-22 15:57:32.178  WARN 28193 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : table "messages" does not exist, skipping
Hibernate: drop table if exists threads cascade
2018-01-22 15:57:32.179  WARN 28193 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
2018-01-22 15:57:32.179  WARN 28193 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : table "threads" does not exist, skipping
Hibernate: drop table if exists users cascade
2018-01-22 15:57:32.179  WARN 28193 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
2018-01-22 15:57:32.179  WARN 28193 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : table "users" does not exist, skipping
Hibernate: drop table if exists users_contacts cascade
2018-01-22 15:57:32.179  WARN 28193 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
2018-01-22 15:57:32.179  WARN 28193 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : table "users_contacts" does not exist, skipping
Hibernate: create table feeds (id  bigserial not null, created_on TIMESTAMP not null, feed_text varchar(255), sender_id serial not null, primary key (id))
Hibernate: create table messages (id  bigserial not null, created_on TIMESTAMP not null, msg_text varchar(255) not null, sender_id serial not null, thread_id serial not null, primary key (id))
Hibernate: create table threads (id  bigserial not null, created_on TIMESTAMP not null, participant_one_id serial not null, participant_two_id serial not null, primary key (id))
Hibernate: create table users (id  bigserial not null, created_on TIMESTAMP not null, active boolean not null, birthdate TIMESTAMP not null, city varchar(100) not null, country varchar(3) not null, email varchar(100) not null, first_name varchar(100) not null, gender varchar(255) not null, last_name varchar(100) not null, password varchar(60) not null, phone_number varchar(20) not null, picture_url varchar(255), updated_on TIMESTAMP not null, verified boolean not null, primary key (id))
Hibernate: create table users_contacts (user_id serial not null, contact_id serial not null)
Hibernate: alter table feeds add constraint FK__USERS__FEEDS__SENDER_ID foreign key (sender_id) references users
Hibernate: alter table messages add constraint FK__THREADS__USERS__SENDER_ID foreign key (sender_id) references users
Hibernate: alter table messages add constraint FK__THREADS__MESSAGES__THREAD_ID foreign key (thread_id) references threads
Hibernate: alter table threads add constraint FK__USERS__THREADS__PARTICIPANT_ONE_ID foreign key (participant_one_id) references users
Hibernate: alter table threads add constraint FK__USERS__THREADS__PARTICIPANT_TWO_ID foreign key (participant_two_id) references users
Hibernate: alter table users_contacts add constraint FK__USERS__USERS__CONTACT_ID foreign key (contact_id) references users
Hibernate: alter table users_contacts add constraint FK__USERS__USERS__USER_ID foreign key (user_id) references users
2018-01-22 15:57:32.235  INFO 28193 --- [           main] o.h.t.schema.internal.SchemaCreatorImpl  : HHH000476: Executing import script 'ScriptSourceInputFromUrl(file:/home/martin/Workspace/zoya/target/classes/import.sql)'

0 answers