PSQLException: 在此 ResultSet 中未找到列名 start_value

huangapple go评论73阅读模式
英文:

PSQLException: The column name start_value was not found in this ResultSet

问题

以下是您提供的内容的翻译:

我在启动Spring Boot Maven应用程序时遇到了PostgreSQL异常。

Maven依赖项:

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <scope>runtime</scope>
</dependency>

属性文件:

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.show-sql=true
spring.datasource.url=jdbc:postgresql://localhost:5432/db
spring.datasource.username=postgres
spring.datasource.password=postgres

异常信息:

org.postgresql.util.PSQLException: 在此ResultSet中找不到列名start_value。
	at org.postgresql.jdbc.PgResultSet.findColumn(PgResultSet.java:2748) ~[postgresql-42.2.16.jar:42.2.16]
	at org.postgresql.jdbc.PgResultSet.getLong(PgResultSet.java:2631) ~[postgresql-42.2.16.jar:42.2.16]
	at com.zaxxer.hikari.pool.HikariProxyResultSet.getLong(HikariProxyResultSet.java) ~[HikariCP-3.4.5.jar:na]
	at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.resultSetStartValueSize(SequenceInformationExtractorLegacyImpl.java:129) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.extractMetadata(SequenceInformationExtractorLegacyImpl.java:59) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.sequenceInformationList(JdbcEnvironmentImpl.java:403) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.<init>(JdbcEnvironmentImpl.java:268) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]

请注意,我已经按照您的要求将代码部分翻译成中文,如有其他需要,请随时告知。

英文:

I am getting Postgresql Exception, when spring-boot maven application is starting up.

Maven Dependency

    &lt;dependency&gt;
    	&lt;groupId&gt;org.postgresql&lt;/groupId&gt;
    	&lt;artifactId&gt;postgresql&lt;/artifactId&gt;
    	&lt;scope&gt;runtime&lt;/scope&gt;
    &lt;/dependency&gt;

Property file

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.show-sql=true
spring.datasource.url=jdbc:postgresql://localhost:5432/db
spring.datasource.username=postgres
spring.datasource.password=postgres

Exception

org.postgresql.util.PSQLException: The column name start_value was not found in this ResultSet.
	at org.postgresql.jdbc.PgResultSet.findColumn(PgResultSet.java:2748) ~[postgresql-42.2.16.jar:42.2.16]
	at org.postgresql.jdbc.PgResultSet.getLong(PgResultSet.java:2631) ~[postgresql-42.2.16.jar:42.2.16]
	at com.zaxxer.hikari.pool.HikariProxyResultSet.getLong(HikariProxyResultSet.java) ~[HikariCP-3.4.5.jar:na]
	at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.resultSetStartValueSize(SequenceInformationExtractorLegacyImpl.java:129) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.extractMetadata(SequenceInformationExtractorLegacyImpl.java:59) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.sequenceInformationList(JdbcEnvironmentImpl.java:403) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.&lt;init&gt;(JdbcEnvironmentImpl.java:268) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at 

答案1

得分: 1

使用以下自定义类,并将其传递给属性。

package com.abc.def;

import org.hibernate.dialect.PostgreSQL95Dialect;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorNoOpImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;

public class PostgresqlCustomDialect extends PostgreSQL95Dialect {

    public String getQuerySequencesString() {
        return "select * from all_sequences";
    }

    public SequenceInformationExtractor getSequenceInformationExtractor() {
        return SequenceInformationExtractorNoOpImpl.INSTANCE;
    }
}

将完全限定的类名放入以下属性中:

p.put("hibernate.dialect", "com.abc.def.PostgresqlCustomDialect");
英文:

Use the below custom class and pass it in the property.

package com.abc.def;

import org.hibernate.dialect.PostgreSQL95Dialect;
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorNoOpImpl;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;

public class PostgresqlCustomDialect extends PostgreSQL95Dialect {

    public String getQuerySequencesString() {
        return &quot;select * from all_sequences&quot;;
    }

    public SequenceInformationExtractor getSequenceInformationExtractor() {
        return SequenceInformationExtractorNoOpImpl.INSTANCE;
    }
}

Put fully qualified class name in below property :

p.put(&quot;hibernate.dialect&quot;,&quot;com.abc.def.PostgresqlCustomDialect&quot;);

huangapple
  • 本文由 发表于 2020年10月3日 13:59:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/64181209.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定