起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4581|回复: 3

[结贴] 主从表

[复制链接]

16

主题

52

帖子

108

积分

初级会员

Rank: 2

积分
108
QQ
发表于 2017-7-21 10:13:43 | 显示全部楼层 |阅读模式
版本: 其它(帖子中说明) 小版本号:
数据库: MySQL 服务器操作系统: Windows 应用服务器: Tomcat
客户端操作系统: Windows 7 浏览器: Chrome
ontology数据建模建了两张表,主从关系,从表只有两个关系(序号和项目明细),想要实现一张主表带一张明细从表,从表中的某一个关系需要一次存储多个值。界面建模时选择了      列表-主从-列表详细      模板,界面如图,在列表中只能添加一列数据,添加两列后就会出现错误:
保存数据失败! ,
执行KSQL出错, KSQL: INSERT INTO ZT_JCXMMXCB ZT_JCXMMXCB(ZT_JCXMMXCB, ZT_JCXMMXCB.version, ZT_JCXMMXCB.fJCXMMX, ZT_JCXMMXCB.fXH, ZT_JCXMMXCB.fZBID) VALUES (:ZT_JCXMMXCB, :version, :fJCXMMX, :fXH, :fZBID)
编码:JUSTEP150210
[url=]隐藏详细[/url]
java.lang.reflect.InvocationTargetException 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:497) at com.justep.system.action.Engine.invokeActions(Native Method) at com.justep.system.action.Engine.invokeActions(Unknown Source) at com.justep.business.server.BusinessServer.doAction(Unknown Source) at com.justep.business.server.BusinessServer.doExcute(Unknown Source) at com.justep.business.server.BusinessServer.excute(Unknown Source) at com.justep.business.server.BusinessServer.excute(Unknown Source) at com.justep.business.server.BusinessServerServlet.execService(Unknown Source) at com.justep.business.server.BusinessServerServlet.service(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) at com.justep.x.bs.BusinessServerServlet.service(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:745) Caused by: com.justep.exception.BusinessException: 编码: JUSTEP150210; 提示: 执行KSQL出错, KSQL: INSERT INTO ZT_JCXMMXCB ZT_JCXMMXCB(ZT_JCXMMXCB, ZT_JCXMMXCB.version, ZT_JCXMMXCB.fJCXMMX, ZT_JCXMMXCB.fXH, ZT_JCXMMXCB.fZBID) VALUES (:ZT_JCXMMXCB, :version, :fJCXMMX, :fXH, :fZBID) at com.justep.exception.BusinessException.create(Unknown Source) at com.justep.system.data.impl.TableUtilsImplement.ksqlInsert(Unknown Source) at com.justep.system.data.impl.TableUtilsImplement.ksqlExecuteUpdate(Unknown Source) at com.justep.system.data.KSQL.executeUpdate(Unknown Source) at com.justep.system.data.KSQL.executeUpdate(Unknown Source) at com.justep.system.data.impl.TableImpl.insert(Unknown Source) at com.justep.system.data.impl.TableImpl.save(Unknown Source) at com.justep.system.data.impl.TableImpl.save(Unknown Source) at com.justep.system.data.BizData.save(Unknown Source) at BizProcedure.save(BizProcedure.java:18) ... 27 more Caused by: com.justep.exception.BusinessException: 编码: JUSTEP150039; 提示: 执行sql: INSERT INTO ZT_JCXMMXCB (ZT_JCXMMXCB.fID, ZT_JCXMMXCB.VERSION, ZT_JCXMMXCB.FJCXMMX, ZT_JCXMMXCB.FXH, ZT_JCXMMXCB.FZBID) VALUES ( ? , ? , ? , ? , ? ), binds: [CD3B7A71711549BEBC253F812F8D7428, 0, 2, null, null]出错 at com.justep.exception.BusinessException.create(Unknown Source) at com.justep.system.ksql.KSQLUtils.execSqlUpdate(Unknown Source) ... 36 more Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'CD3B7A71711549BEBC253F812F8D7428' for key 'PRIMARY' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at com.mysql.jdbc.Util.handleNewInstance(Util.java:400) at com.mysql.jdbc.Util.getInstance(Util.java:383) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3847) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3783) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2447) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2594) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2545) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1901) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2113) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2049) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2034) at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) ... 37 more


能不能实现在主表中添加一条数据而在从列表中添加多条数据?要如何设置
1.png

37

主题

132

帖子

422

积分

中级会员

Rank: 3Rank: 3

积分
422
QQ
发表于 2017-7-21 10:36:56 | 显示全部楼层
我也碰到这个问题,数据建模的时候,从表的主键会变成主表的主键,而不是外键指向主键,导致主从表1对多的关系没法实现,找不到哪里改...
回复 支持 反对

使用道具 举报

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
36069
发表于 2017-7-21 11:23:42 | 显示全部楼层
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'CD3B7A71711549BEBC253F812F8D7428' for key 'PRIMARY'

这个错误是指插入的主键值重复了
如果主表的数据是选择的,选择的时候不要选择主键值
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

16

主题

52

帖子

108

积分

初级会员

Rank: 2

积分
108
QQ
 楼主| 发表于 2017-7-21 13:50:06 | 显示全部楼层
好的,我把界面重新建模后,可以实现了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-11-26 16:37 , Processed in 0.113734 second(s), 28 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表