Video statistics contraintes
Bonsoir
J' ai une table video qui contient comme champ : id , titre
et une autre table video_statistics qui contient asset_id, comments_count
Mon probleme est ce message d'erreur :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:343)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:193)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:--- The error occurred in sqlmap/statistics.xml.
--- The error occurred while applying a parameter map.
--- Check the createStatisticsForVideo-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`sohorse/video_statistics`, CONSTRAINT `fk_video_statistics_1` FOREIGN KEY (`asset_id`) REFERENCES `video` (`id`) ON DELETE CASCADE) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:447)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:59)
at com.sohorse.persistence.sqlmap.VideoDaoImpl.getStats(VideoDaoImpl.java:176)
... 44 common frames omitted
Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`sohorse/video_statistics`, CONSTRAINT `fk_video_statistics_1` FOREIGN KEY (`asset_id`) REFERENCES `video` (`id`) ON DELETE CASCADE) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1169)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:693)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:794)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:81)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
... 48 common frames omitted |
le probleme vient puisqu
Code:
Unable to find stats of video #1182
Sachant que la table video ne contient plus cet Id pourtant la table faire tjs reference à lui.
le code source des tables :
Code:
1 2 3 4 5 6 7 8 9 10 11
| CREATE TABLE video (
id int(11) NOT NULL auto_increment,
title varchar(50) NOT NULL,
PRIMARY KEY (id),
KEY fk_video_1 (owner_id),
) ENGINE=InnoDB AUTO_INCREMENT=640 DEFAULT CHARSET=utf8; |
Code:
1 2 3 4 5 6 7 8 9 10 11
| CREATE TABLE video_statistics (
asset_id int(11) NOT NULL,
comments_count int(11) NOT NULL default 0,
PRIMARY KEY (asset_id),
CONSTRAINT fk_video_statistics_1 FOREIGN KEY (asset_id) REFERENCES video (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |