jfinal postgresql model映射表 总说关系不存在

    (Plugins me) {
DruidPlugin druidPlugin = ()me.add(druidPlugin)ActiveRecordPlugin arp = ActiveRecordPlugin(druidPlugin)arp.addMapping(GradeModel.)arp.setDialect(PostgreSqlDialect())me.add(arp)}

1-Oct-2018 16:14:27.461 严重 [RMI TCP Connection(3)-127.0.0.1] com.jfinal.core.Config.error Plugin start error: com.jfinal.plugin.activerecord.ActiveRecordPlugin. 

org.postgresql.util.PSQLException: 错误: 关系 "grade" 不存在

  位置:15

 com.jfinal.plugin.activerecord.ActiveRecordException: org.postgresql.util.PSQLException: 错误: 关系 "grade" 不存在

  位置:15

at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:55)

at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:226)

at com.jfinal.core.Config.startPlugins(Config.java:128)

at com.jfinal.core.Config.configPluginWithOrder(Config.java:71)

at com.jfinal.core.Config.configJFinal(Config.java:56)

at com.jfinal.core.JFinal.init(JFinal.java:63)

at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)

at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285)

at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266)

at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)

at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4747)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5389)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:755)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:731)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)

at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1730)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:484)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:433)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)

at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)

at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)

at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)

at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)

at sun.rmi.transport.Transport$1.run(Transport.java:200)

at sun.rmi.transport.Transport$1.run(Transport.java:197)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Transport.java:196)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)


这是咋回事

评论区

Mr.moster

2018-10-11 16:17

CREATE TABLE public.grade
(
stu_id integer NOT NULL,
score jsonb,
CONSTRAINT grade_pkey PRIMARY KEY (stu_id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.grade
OWNER TO postgres;

这是我的sql语句

JFinal

2018-10-11 16:43

注意表名的大小写,以及表名前后有无空格,还要注意一下 grade 是不是 postgresql 的保留字,试着换一个表名看看会不会出这个错,用排除法定位错误

Mr.moster

2018-10-11 16:58

create table "stu_grad"
(
"stu_id" integer not null primary key,
"score" jsonb
)

arp.addMapping("stu_grad","stu_id", GradeModel.class);
arp.setDialect(new PostgreSqlDialect());

还是不行啊,换了个名字,大小写也一致 @JFinal

Mr.moster

2018-10-11 17:02

@JFinal 在jfinal外都可以查出来数据,就是在jfinal里怎么都不行,方言也添加了,添加双引号,就是严格区分大小写呗,方言中不是自动在表名前后加双引号吗,这是咋回事

JFinal

2018-10-12 09:06

@Mr.moster jfinal 在底层就是将你的 sql + para 直接扔给 JDBC 处理的,所以只要是 JDBC 支持那 jfinal 一定就支持了

因此,用纯 JDBC 做个测试就知道原因了,具体办法是:
// 通过 jfinal 的工具类拿到 JDBC 的数据库连接
Connection conn = DbKit.getConfig().getConnection();

// 用纯 JDBC 的方法执行你自己的 sql
conn. prepareStatement(sql);
pstmt. executeQuery();

以上的 sql 参数是你的代码出异常时的那个 sql,将其复制进来即可,可能需要单步调试才能得到这个 sql

通过上面的方式你会发现,JDBC 本身不支持这条 sql,解决办法自然就出来了

Mr.moster

2018-10-13 09:44

@JFinal 那问题解决了,我还有一个问题,就是jfinal怎样把json数据类型的数据插入数据库呢,数据库的字段类型为json

热门反馈

扫码入社