The specific errors are as follows:
at org. springframework . data . repository . core . support . RepositoryFac torySupport$ImpLementat ionMe thodExecutionInterceptor . invoke (RepositoryFactorysupport . java:640)
at org. springframework . aop . framework . ReflectiveMethodInvocation. proceed(RefLectiveMethodInvocation. java:186)
at org. springframework . data . repository . core . support . QueryExecutorMe thodInterceptor . doInvoke (QueryExecutorMethodInterceptor. java:164)
at org. springframework . data . repository . core . support . QueryExecutorMe thodInterceptor . invoke(QueryExecutorMe thodInterceptor . java:139)
at org. springframework . aop. framework . ReflectiveMe thodInvocation. proceed(ReflectiveMethodInvocation. java:186)
at org. springframework . data . projection. DefaultMe thodInvokingNethodInterceptor . invoke(DefauL tMe thodInvokingNethodInterceptor . java:81)
at org. springframework . aop. framework . ReflectiveMe thodInvocation. proceed(ReflectiveMethodInvocation. java:186)
at org. springframework . transaction . interceptor. TransactionInterceptor$1 . proceedWithInvocation(TransactionInterceptor . java:123)
at org. springframework . transaction . interceptor. TransactionAspectSupport . invokeWithinTransaction(TransactionAspectSupport. java:388)
at org. springframework. transaction. interceptor . TransactionInterceptor . invoke(TransactionInterceptor . java:119)
at org. springframework . aop . framework . ReflectiveMe thodInvocation . proceed(RefLectiveMethodInvocation. java:186]
at org. springframework . dao . support . PersistenceExceptionTranslationInterceptor invoke(PersistenceExceptionTranslationInterceptor。java:137)
... 124 common frames omitted
Caused by: org. postgresql. util. PSQLException: ERROR: coLumn "job_ params" is of type oid but expression is of type character varying
建议: You will need
to rewrite or cas
the expression.
位置: 536
at org. postgresql. core . v3. QueryExecutorImpL. receiveErrorResponse(QueryExecutorImpL. java:2532)
at org. postgresql. core . v3. QueryExecutorImpL . processResults(QueryExecutorImpL. java:2267)
at org . postgresql. core . v3. QueryExecutor ImpL. execute (QueryExecutorImpL. java :312)
at org . postgresql. jdbc . PgStatement . executeInternal(PgStatement. java:448)
at org. postgresqL. jdbc . PgStatement . execute (PgStatement. java:369)
at org. postgresql. jdbc . PgPreparedStatement . executeWi thFlags(PaPreparedstatement . java:153)
at org . postgresql. jdbc . PgPreparedStatement . executeUpdate (PgPreparedStatement : java:119)
at com. zaxxer . hikari . pool . ProxyPreparedStatement . executeUpdate(ProxyPreparedStatement . java:61)
at com. zaxxer . hikari . pooL. HikariProxyPreparedStatement . executeUpdate (HikariProxyPreparedStatement. java) <1 internal line>
166 common frames omitted
Because users only need to create a database and powerjob-server automatically creates tables at runtime, the table building module is basically the same. There is no problem with mysql, but switching to a postgres database will cause field inconsistencies and errors.
After reading a lot of information, the official also gave a solution:
- Caused by: org.postgresql.util.PSQLException: Large object cannot be used in auto-confirm transaction mode
- JpaSystemException: Unable to access lob stream
If you have similar errors, please refer to the following ISSUE
- If JPA has automatically created tables, please delete all tables related to powerjob first.
- Add
spring.datasource.remote.hibernate.properties.hibernate.dialect=tech.powerjob.server.persistence.config.dialect.PowerJobPGDialect
in the configuration file to enable the postgreSQL dedicated dialect processor, restart the server & automatically create tables.
After I followed this step, I found that the problem still could not be completely solved, and an error was still reported when creating a new task.
According to the official solution, you can follow similar operations and create a new configuration class in the system. Used to replace the oid type with the text type in postgres when creating a table. The code is as follows:
/**
* description:
* @author litong
* @date 2023/9/19
*/
public class AdpPostgreSQLDialect extends PostgreSQL10Dialect {
public AdpPostgreSQLDialect() {
super();
registerColumnType(Types.BLOB, "bytea");
registerColumnType(Types.CLOB, "text");
}
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
switch (sqlTypeDescriptor.getSqlType()) {
case Types.CLOB:
return LongVarcharTypeDescriptor.INSTANCE;
case Types.BLOB:
return LongVarbinaryTypeDescriptor.INSTANCE;
case Types.NCLOB:
return LongVarbinaryTypeDescriptor.INSTANCE;
}
return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
}
After writing this class, we activate it in the application-product.properties configuration file
spring.datasource.remote.hibernate.properties.hibernate.dialect=tech.powerjob.server.persistence.config.dialect.AdpPostgreSQLDialect
Following the = sign is the fully qualified name of your class, which can be changed depending on your personal circumstances. After modification, you can use powerjob-server normally to schedule scheduled tasks.