-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problem Bidirectional Asociations
PostPosted: Tue Oct 28, 2008 7:47 am 
Newbie

Joined: Tue Oct 28, 2008 7:33 am
Posts: 2
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 28, 2008 10:38 am 
Newbie

Joined: Tue Oct 28, 2008 7:33 am
Posts: 2
please help me.., jeje


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 28, 2008 6:15 pm 
Beginner
Beginner

Joined: Tue Oct 30, 2007 7:57 am
Posts: 47
The problem is that you are trying to delete or update a record that is needed by another table. For example, perhaps you are trying to delete a channel, without deleting first the channel language. Write the hibernate code you are using, please. It will help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.