2018-09-07 12:54

@JFinal
Exception in thread "main" java.lang.RuntimeException: java.sql.SQLFeatureNotSupportedException
at com.jfinal.plugin.activerecord.generator.MetaBuilder.build(MetaBuilder.java:102)
at com.jfinal.plugin.activerecord.generator.Generator.generate(Generator.java:262)
at com.GenModel.TestGeneratorModel.main(TestGeneratorModel.java:59)
Caused by: java.sql.SQLFeatureNotSupportedException
at com.alibaba.druid.pool.DruidPooledConnection.getSchema(DruidPooledConnection.java:1191)
at com.GenModel.TestGeneratorModel$_MetaBuilder.buildPrimaryKey(TestGeneratorModel.java:88)
at com.jfinal.plugin.activerecord.generator.MetaBuilder.build(MetaBuilder.java:96)
... 2 more

2018-09-06 19:10

@JFinal 问题在于以下我描述的地方,如果源码可以做一下改进应该使用起来更好了。oracle实例中,包含该表名字的schema 有多个,且ojdbc6 conn.getCata() 返回了null ,就出现了该问题。

2018-09-06 19:06

问题在于 Jfinal 3.x中的 MetaBuilder 对象,中的方法:
protected void buildPrimaryKey(TableMeta tableMeta) throws SQLException {
ResultSet rs = dbMeta.getPrimaryKeys(conn.getCatalog(), null, tableMeta.name);

String primaryKey = "";
int index = 0;
while (rs.next()) {
if (index++ > 0) {
primaryKey += ",";
}
primaryKey += rs.getString("COLUMN_NAME");
}
if (StrKit.isBlank(primaryKey)) {
throw new RuntimeException("primaryKey of table \"" + tableMeta.name + "\" required by active record pattern");
}
tableMeta.primaryKey = primaryKey;
rs.close();
}

问题代码在于,
ResultSet rs = dbMeta.getPrimaryKeys(conn.getCatalog(), null, tableMeta.name);
由于你使用的 ojdbc6 驱动,conn.getCatalog() 没有返回数据库 schema ,而第二个参数,schema又传入的 null参数,导致你取到了 数据库实例的多个 包含该表名的schema中主键记录 。如果你第二个参数传入 schema 就生成正常了

2017-06-28 21:46

@二郎 对头,是这样的。