Précédent   Forum des professionnels en informatique > Bases de données > MySQL > SQL Procédural
SQL Procédural Forum d'entraide sur les triggers, les procédures stockées et les fonctions en MySQL
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 17/03/2008, 22h08   #1
Candidat au titre de Membre du Club
 
Inscription : juillet 2007
Messages : 60
Détails du profil
Informations personnelles :
Âge : 29

Informations forums :
Inscription : juillet 2007
Messages : 60
Points : 10
Points : 10
Par défaut 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;
zorro13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/03/2008, 13h01   #2
Membre éclairé
 
Avatar de nicoaix
 
Homme
Chef de projet MOA
Inscription : décembre 2004
Messages : 561
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 37
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Chef de projet MOA
Secteur : Administration - Collectivité locale

Informations forums :
Inscription : décembre 2004
Messages : 561
Points : 325
Points : 325
Il y a visiblement un problème de référence avec les clés de tes tables.
nicoaix est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 09h12.


 
 
 
 
Partenaires

Hébergement Web