10000 使用PG数据库,还是会出现oid类型的列,使用文档所说的如下配置类激活了,没有用。解决方法我放下面了 · Issue #750 · PowerJob/PowerJob · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

使用PG数据库,还是会出现oid类型的列,使用文档所说的如下配置类激活了,没有用。解决方法我放下面了 #750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
litong0531 opened this issue Sep 22, 2023 · 4 comments
Labels
question Further information is requested

Comments

@litong0531
Copy link

这个类不能起到效果
public class PowerJobPGDialect extends PostgreSQL10Dialect {

/**
 * 使用 {@link Types#LONGVARCHAR} 覆盖 {@link Types#CLOB} 类型
 *
 * 注意,如果在 PG 库创建表时使用的列类型为 oid ,那么这样会导致没法正确读取数据
 * 在 PowerJob 中能这样用是因为 PowerJob 的所有实体类中被 @Lob 注解标记的列对应数据库中的字段类型都是 text
 * 另外还需要注意数据库版本,如果是 10.x 以前的,需自行提供一个合适的 Dialect 类(选择合适的版本继承)
 *
 * 更多内容请关注该 issues:https://github.com/PowerJob/PowerJob/issues/153
 */
@Override
public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
    return Types.CLOB == sqlCode ? LongVarcharTypeDescriptor.INSTANCE : null;
}

}

解决方法:
重写一个类,使用配置文件指定全限定名路径来激活
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);
}

}
这个什么时候可以更新到版本中去?还是我自己本地打包自己用?

@litong0531 litong0531 added the question Further information is requested label Sep 22, 2023
@limng06
Copy link
limng06 commented Oct 8, 2023

这种不可能也不应该放代码里去的,毕竟要依赖数据库方言包和驱动,这种情况应该优先自己打包。

@litong0531
Copy link
Author

好的,知道了,已经拉下源码,自己改了打包在用了

@andychyiyi
Copy link

AdpPostgreSQLDialect这个可以的,终于摆脱烦人的oid了,oid太局限了,之前旧数据用的text,升级用oid转换会失败,希望作者引用此类,
我是在4.0.1升级5.0.1搞结构同步这块踩的坑。

@KFCFans
Copy link
Member
KFCFans commented Aug 10, 2024

AdpPostgreSQLDialect这个可以的,终于摆脱烦人的oid了,oid太局限了,之前旧数据用的text,升级用oid转换会失败,希望作者引用此类, 我是在4.0.1升级5.0.1搞结构同步这块踩的坑。

考虑到 PG 相关的问题确实比较多,这个类我也集成到代码中了,到时候大家自己按需选择吧😂

Uh oh!

There was an error while loading. Please reload this page.

@KFCFans KFCFans closed this as completed Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants
0