Hibernate Postgress exception Error accessing index information

263
21 января 2019, 13:00

Сделал таблички: Магазин(Shop) Товар(Item) Табличка связи(item_x_shop)

Вот Shop:

package DataModel;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@Entity
public class Shop {
    private int shopId;
    private String shopName;
    private String email;
    private String phoneMobile;
    private Timestamp validFromDttm;
    private Timestamp validToDttm;
    private List<ItemXShop> items;
    @Id
    @Column(name = "shop_id", nullable = false)
    public int getShopId() {
        return shopId;
    }
    public void setShopId(int shopId) {
        this.shopId = shopId;
    }
    @Basic
    @Column(name = "shop_name", nullable = true, length = 100)
    public String getShopName() {
        return shopName;
    }
    public void setShopName(String shopName) {
        this.shopName = shopName;
    }
    @Basic
    @Column(name = "email", nullable = true, length = 100)
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    @Basic
    @Column(name = "phone_mobile", nullable = true, length = 100)
    public String getPhoneMobile() {
        return phoneMobile;
    }
    public void setPhoneMobile(String phoneMobile) {
        this.phoneMobile = phoneMobile;
    }
    @Basic
    @Column(name = "valid_from_dttm", nullable = true)
    public Timestamp getValidFromDttm() {
        return validFromDttm;
    }
    public void setValidFromDttm(Timestamp validFromDttm) {
        this.validFromDttm = validFromDttm;
    }
    @Basic
    @Column(name = "valid_to_dttm", nullable = true)
    public Timestamp getValidToDttm() {
        return validToDttm;
    }
    public void setValidToDttm(Timestamp validToDttm) {
        this.validToDttm = validToDttm;
    }
    @OneToMany
    @JoinTable( catalog = "postgres", schema = "public", name = "item_x_shop",
            joinColumns = @JoinColumn(name = "item_id"),
            inverseJoinColumns = @JoinColumn(name = "shop_id"))
    public List<ItemXShop> getItems() {
        return items;
    }
    public void setItems(List<ItemXShop> items) {
        this.items = items;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Shop shop = (Shop) o;
        if (shopId != shop.shopId) return false;
        if (shopName != null ? !shopName.equals(shop.shopName) : shop.shopName != null) return false;
        if (email != null ? !email.equals(shop.email) : shop.email != null) return false;
        if (phoneMobile != null ? !phoneMobile.equals(shop.phoneMobile) : shop.phoneMobile != null) return false;
        if (validFromDttm != null ? !validFromDttm.equals(shop.validFromDttm) : shop.validFromDttm != null)
            return false;
        if (validToDttm != null ? !validToDttm.equals(shop.validToDttm) : shop.validToDttm != null) return false;
        return true;
    }
    @Override
    public int hashCode() {
        int result = shopId;
        result = 31 * result + (shopName != null ? shopName.hashCode() : 0);
        result = 31 * result + (email != null ? email.hashCode() : 0);
        result = 31 * result + (phoneMobile != null ? phoneMobile.hashCode() : 0);
        result = 31 * result + (validFromDttm != null ? validFromDttm.hashCode() : 0);
        result = 31 * result + (validToDttm != null ? validToDttm.hashCode() : 0);
        return result;
    }
}

Вот Item :

package DataModel;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@Entity
public class Shop {
    private int shopId;
    private String shopName;
    private String email;
    private String phoneMobile;
    private Timestamp validFromDttm;
    private Timestamp validToDttm;
    private List<ItemXShop> items;
    @Id
    @Column(name = "shop_id", nullable = false)
    public int getShopId() {
        return shopId;
    }
    public void setShopId(int shopId) {
        this.shopId = shopId;
    }
    @Basic
    @Column(name = "shop_name", nullable = true, length = 100)
    public String getShopName() {
        return shopName;
    }
    public void setShopName(String shopName) {
        this.shopName = shopName;
    }
    @Basic
    @Column(name = "email", nullable = true, length = 100)
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    @Basic
    @Column(name = "phone_mobile", nullable = true, length = 100)
    public String getPhoneMobile() {
        return phoneMobile;
    }
    public void setPhoneMobile(String phoneMobile) {
        this.phoneMobile = phoneMobile;
    }
    @Basic
    @Column(name = "valid_from_dttm", nullable = true)
    public Timestamp getValidFromDttm() {
        return validFromDttm;
    }
    public void setValidFromDttm(Timestamp validFromDttm) {
        this.validFromDttm = validFromDttm;
    }
    @Basic
    @Column(name = "valid_to_dttm", nullable = true)
    public Timestamp getValidToDttm() {
        return validToDttm;
    }
    public void setValidToDttm(Timestamp validToDttm) {
        this.validToDttm = validToDttm;
    }
    @OneToMany
    @JoinTable( catalog = "postgres", schema = "public", name = "item_x_shop",
            joinColumns = @JoinColumn(name = "item_id"),
            inverseJoinColumns = @JoinColumn(name = "shop_id"))
    public List<ItemXShop> getItems() {
        return items;
    }
    public void setItems(List<ItemXShop> items) {
        this.items = items;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Shop shop = (Shop) o;
        if (shopId != shop.shopId) return false;
        if (shopName != null ? !shopName.equals(shop.shopName) : shop.shopName != null) return false;
        if (email != null ? !email.equals(shop.email) : shop.email != null) return false;
        if (phoneMobile != null ? !phoneMobile.equals(shop.phoneMobile) : shop.phoneMobile != null) return false;
        if (validFromDttm != null ? !validFromDttm.equals(shop.validFromDttm) : shop.validFromDttm != null)
            return false;
        if (validToDttm != null ? !validToDttm.equals(shop.validToDttm) : shop.validToDttm != null) return false;
        return true;
    }
    @Override
    public int hashCode() {
        int result = shopId;
        result = 31 * result + (shopName != null ? shopName.hashCode() : 0);
        result = 31 * result + (email != null ? email.hashCode() : 0);
        result = 31 * result + (phoneMobile != null ? phoneMobile.hashCode() : 0);
        result = 31 * result + (validFromDttm != null ? validFromDttm.hashCode() : 0);
        result = 31 * result + (validToDttm != null ? validToDttm.hashCode() : 0);
        return result;
    }
}

Вот связка:

package DataModel;
import javax.persistence.*;
import java.sql.Timestamp;
@Entity
@Table(name = "item_x_shop", schema = "public", catalog = "postgres")
public class ItemXShop {
    private int itemId;
    private int shopId;
    private Timestamp validFromDttm;
    private Timestamp validToDttm;
    @Id
    private int itemXShopId;
    @Basic
    @Column(name = "item_id", nullable = false)
    public int getItemId() {
        return itemId;
    }
    public void setItemId(int itemId) {
        this.itemId = itemId;
    }
    @Basic
    @Column(name = "shop_id", nullable = false)
    public int getShopId() {
        return shopId;
    }
    public void setShopId(int shopId) {
        this.shopId = shopId;
    }
    @Basic
    @Column(name = "valid_from_dttm", nullable = false)
    public Timestamp getValidFromDttm() {
        return validFromDttm;
    }
    public void setValidFromDttm(Timestamp validFromDttm) {
        this.validFromDttm = validFromDttm;
    }
    @Basic
    @Column(name = "valid_to_dttm", nullable = false)
    public Timestamp getValidToDttm() {
        return validToDttm;
    }
    public void setValidToDttm(Timestamp validToDttm) {
        this.validToDttm = validToDttm;
    }
    @Id
    @Column(name = "item_x_shop_id", nullable = false)
    public int getItemXShopId() {
        return itemXShopId;
    }
    public void setItemXShopId(int itemXShopId) {
        this.itemXShopId = itemXShopId;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ItemXShop itemXShop = (ItemXShop) o;
        if (itemId != itemXShop.itemId) return false;
        if (shopId != itemXShop.shopId) return false;
        if (itemXShopId != itemXShop.itemXShopId) return false;
        if (validFromDttm != null ? !validFromDttm.equals(itemXShop.validFromDttm) : itemXShop.validFromDttm != null)
            return false;
        if (validToDttm != null ? !validToDttm.equals(itemXShop.validToDttm) : itemXShop.validToDttm != null)
            return false;
        return true;
    }
    @Override
    public int hashCode() {
        int result = itemId;
        result = 31 * result + shopId;
        result = 31 * result + (validFromDttm != null ? validFromDttm.hashCode() : 0);
        result = 31 * result + (validToDttm != null ? validToDttm.hashCode() : 0);
        result = 31 * result + itemXShopId;
        return result;
    }
}

Получаю следующий Exception:

Исключение!org.hibernate.exception.SQLGrammarException: Error accessing index information: item_x_shop
org.hibernate.exception.SQLGrammarException: Error accessing index information: item_x_shop
    at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106)
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
    at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.convertSQLException(InformationExtractorJdbcDatabaseMetaDataImpl.java:98)
    at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getIndexes(InformationExtractorJdbcDatabaseMetaDataImpl.java:759)
    at org.hibernate.tool.schema.extract.internal.TableInformationImpl.indexes(TableInformationImpl.java:122)
    at org.hibernate.tool.schema.extract.internal.TableInformationImpl.getIndex(TableInformationImpl.java:138)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyUniqueKeys(AbstractSchemaMigrator.java:370)
    at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:85)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:207)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
    at DBLayout.HibernateUtil.getSessionFactory(HibernateUtil.java:28)
    at Managers.ShopManager.getAllShop(ShopManager.java:11)
    at controllers.controller.getShop(controller.java:17)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: org.postgresql.util.PSQLException: ERROR: column i.indproc does not exist
  Подсказка: Perhaps you meant to reference the column "i.indpred".
  Позиция: 610
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
    at org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.getIndexInfo(AbstractJdbc2DatabaseMetaData.java:4127)
    at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getIndexes(InformationExtractorJdbcDatabaseMetaDataImpl.java:719)
    ... 53 more

Я не понимаю, какие проблемы с доступом к индексу item_x_shop?
Что за столбец - i.indrep? Я новичок в Hibernate, помогите пожалуйста.

READ ALSO
Scanner пропускает строки

Scanner пропускает строки

проблема заключается в том что при считывании данных с клавиатуры с помощью методов класса Scanner, он пропускает строки (Date и Notes)Насколько я понял...

171