Hi, I have a big problem with the asociation
Mapping documents
Category Model
<class name="Category" table="cat_category">
<id name="id" column="CATEG_ID" unsaved-value="null">
<generator class="identity" />
</id>
<set name="canales" cascade="all" inverse="true">
<key column="ID_CATEG" not-null="true" on-delete="cascade"/>
<one-to-many class="com.wn21.verne21.sc.news.model.Channel"/>
</set>
<set name="noticias" cascade="all" inverse="true">
<key column="ID_CATEG" not-null="true" on-delete="cascade"/>
<one-to-many class="com.wn21.verne21.sc.news.model.News"/>
</set>
</class>
Channel Model
<class name="Channel" lazy="false" table="news_channel">
<id name="id" column="ID" unsaved-value="null">
<generator class="identity" />
</id>
<many-to-one name="category" lazy="false" cascade="none" class="com.wn21.verne21.catalogo.Category" column="ID_CATEG"/>
<set name="idiomasCanal" cascade="all" inverse="true">
<key column="ID_CHANNEL" />
<one-to-many class="ChannelLang"/>
</set>
<set name="noticias" cascade="all" inverse="true">
<key column="ID_CHANNEL" />
<one-to-many class="News"/>
</set>
<property name="estado" column="ESTADO"/>
</class>
ChannelLang Model
<class name="ChannelLang" table="news_channel_lang">
<composite-id>
<key-many-to-one name="language" class="com.wn21.verne21.language.Language" column="ID_LANGUAGE"/>
<key-many-to-one name="channel" class="com.wn21.verne21.sc.news.model.Channel" column="ID_CHANNEL"/>
</composite-id>
<property name="name" column="NAME" />
</class>
Full stack trace of any exception that occurs
2008-10-28 12:44:24,604 util.JDBCExceptionReporter.logExceptions - Cannot delete or update a parent row: a foreign key constraint fails (`verne21/news_channel_lang`, CONSTRAINT `FK60EFC596C8BB48A0` FOREIGN KEY (`ID_CHANNEL`) REFERENCES `news_channel` (`ID`))
2008-10-28 12:44:24,614 interceptor.HibernateInterceptor.intercept - HibernateException in execute()
org.hibernate.exception.ConstraintViolationException: could not execute update query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:84)
at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:326)
at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:202)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1111)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:94)
at com.wn21.verne21.catalogo.UtilCategory.borrarDescendientes(UtilCategory.java:377)
at com.wn21.verne21.catalogo.UtilCategory.borrarDescendientes(UtilCategory.java:397)
at com.wn21.verne21.catalogo.UtilCategory.borrarDescendientes(UtilCategory.java:397)
at com.wn21.verne21.catalogo.Catalogo.deleteCategory(Catalogo.java:443)
at com.wn21.verne21.catalogo.Catalogo.deleteCategory(Catalogo.java:457)
at com.wn21.verne21.sc.navegacion.action.DeleteCategoryAction.go(DeleteCategoryAction.java:47)
at com.wn21.verne21.AbstractAction.execute(AbstractAction.java:90)
at sun.reflect.GeneratedMethodAccessor305.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:364)
at com.opensymphony.xwork.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:216)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
at com.wn21.verne21.sc.login.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:48)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
at com.wn21.verne21.sc.comunes.interceptor.HibernateInterceptor.intercept(HibernateInterceptor.java:35)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:113)
at com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(DispatcherUtils.java:225)
at com.opensymphony.webwork.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:202)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:59)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`verne21/news_channel_lang`, CONSTRAINT `FK60EFC596C8BB48A0` FOREIGN KEY (`ID_CHANNEL`) REFERENCES `news_channel` (`ID`))
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:1160)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:75)
... 48 more
2008-10-28 12:44:24,622
The database is Mysql
Any idea ¿?.
Thanks
|