Skip to content
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

clickhouse数据库可以适配吗? #55

Open
activepirate opened this issue Nov 26, 2020 · 6 comments
Open

clickhouse数据库可以适配吗? #55

activepirate opened this issue Nov 26, 2020 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@activepirate
Copy link
Collaborator

clickhouse表不能设置主键自增,现在的版本,支不支持clickhouse数据库阿

@catchex
Copy link
Member

catchex commented Nov 26, 2020

这块还在开发中。有兴趣你可以提交PR

@catchex catchex added the question Further information is requested label Nov 26, 2020
@activepirate
Copy link
Collaborator Author

objsql调用jdbc插入部分

stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);

clickhouse驱动对prepareStatement方法的实现
https://github.com/ClickHouse/clickhouse-jdbc/blob/master/src/main/java/ru/yandex/clickhouse/ClickHouseConnectionImpl.java#L337

@Override
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
    throw new SQLFeatureNotSupportedException();
}

@catchex
Copy link
Member

catchex commented Dec 3, 2020

这应该是数据库适配,你先手工调整一下,我查看一下是否有API 判断是否支持Statement.RETURN_GENERATED_KEYS 这类API,如果没有,可以在外层catch SQLFeatureNotSupportedException 异常

@activepirate
Copy link
Collaborator Author

我觉得这块可以考虑
如果domains设置主键自增,调用

public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)

如果domains设置非主键自增,调用

public PreparedStatement prepareStatement(String sql)

@catchex
Copy link
Member

catchex commented Dec 3, 2020

你的想法是可行的,但不够健全,如果Clickhouse 有大量的DomainModel 都要去设计 autoGenerated 有点麻烦,还是要增强底层程序的健壮性,这是API 设计的基本特性

@zhilinli123
Copy link

@catchex @activepirate 请问两位最后是怎么解决该问题的 我现在也遇到了

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

3 participants