-->
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.  [ 2 posts ] 
Author Message
 Post subject: help deleting items from a collection
PostPosted: Sat Jun 04, 2005 3:07 pm 
Newbie

Joined: Sat Jun 04, 2005 2:35 pm
Posts: 7
I am sure this is a newby question, but it sure is taking the wind out of my sails. I am trying to delete an item from a Set collection. I am using Hibernate 2, JBoss, Informix, and XDoclet. The basic problem is that i get a ConstraintViolationException when Hibernate tries to commit the changes. Although the root problem appears to be a not-null violation on the foreign key (even though I have told Hibernate that the column is not-null).

My deletion code is:
Code:
        // this returns a hibernated object
        UserRole r = getRole(roletype);
        if(r!=null) {
            // this removes the object from its Set
            roles.remove(r);
        }


The Set xml looks like:
Code:
        <set
            name="roles"
            lazy="true"
            cascade="all"
            sort="unsorted"
        >
              <key>
                <column
                    name="login_fk"
                    not-null="true"
                />
              </key>
              <one-to-many
                  class="com.infinity.dao.UserRole"
              />
        </set>


The JBoss output looks like:
Code:
11:28:35,947 WARN  [JDBCExceptionReporter] SQL Error: -391, SQLState: 23000
11:28:35,947 ERROR [JDBCExceptionReporter] Cannot insert a null into column (userrole.login_fk).
11:28:35,947 ERROR [SessionImpl] Could not synchronize database state with session
11:28:35,947 ERROR [Engine] ApplicationDispatcher[] Servlet.service() for servlet jsp threw exception
net.sf.hibernate.exception.ConstraintViolationException: could not delete collection rows: [com.infinity.dao.Login.roles#31]
        at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:62)
        at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
        at net.sf.hibernate.collection.AbstractCollectionPersister.convert(AbstractCollectionPersister.java:728)
        at net.sf.hibernate.collection.AbstractCollectionPersister.deleteRows(AbstractCollectionPersister.java:584)
        at net.sf.hibernate.impl.ScheduledCollectionUpdate.execute(ScheduledCollectionUpdate.java:47)
        at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
        at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435)
        at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2395)
        at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1821)
        at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1578)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
        at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
        at com.infinity.dao.Admin.queryUserRoles(Admin.java:76)
        at org.apache.jsp.login_005flist_jsp._jspService(login_005flist_jsp.java:163)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
        at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
        at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
        at org.apache.jsp.login_005fprofile_jsp._jspService(login_005fprofile_jsp.java:146)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
        at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
        at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.SQLException: Cannot insert a null into column (userrole.login_fk).
        at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3039)
        at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3353)
        at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2254)
        at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2174)
        at com.informix.jdbc.IfxSqli.executeCommand(IfxSqli.java:718)
        at com.informix.jdbc.IfxResultSet.executeUpdate(IfxResultSet.java:305)
        at com.informix.jdbc.IfxStatement.executeUpdateImpl(IfxStatement.java:850)
        at com.informix.jdbc.IfxPreparedStatement.executeUpdate(IfxPreparedStatement.java:281)
        at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:335)
        at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
        at net.sf.hibernate.collection.AbstractCollectionPersister.deleteRows(AbstractCollectionPersister.java:568)
        ... 59 more
11:28:35,957 ERROR [Engine] StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
net.sf.hibernate.exception.ConstraintViolationException: could not delete collection rows: [com.infinity.dao.Login.roles#31]
        at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:62)
        at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
        at net.sf.hibernate.collection.AbstractCollectionPersister.convert(AbstractCollectionPersister.java:728)
        at net.sf.hibernate.collection.AbstractCollectionPersister.deleteRows(AbstractCollectionPersister.java:584)
        at net.sf.hibernate.impl.ScheduledCollectionUpdate.execute(ScheduledCollectionUpdate.java:47)
        at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
        at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435)
        at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2395)
        at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1821)
        at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1578)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
        at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
        at com.infinity.dao.Admin.queryUserRoles(Admin.java:76)
        at org.apache.jsp.login_005flist_jsp._jspService(login_005flist_jsp.java:163)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
        at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
        at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
        at org.apache.jsp.login_005fprofile_jsp._jspService(login_005fprofile_jsp.java:146)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
        at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
        at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.SQLException: Cannot insert a null into column (userrole.login_fk).
        at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3039)
        at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3353)
        at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2254)
        at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2174)
        at com.informix.jdbc.IfxSqli.executeCommand(IfxSqli.java:718)
        at com.informix.jdbc.IfxResultSet.executeUpdate(IfxResultSet.java:305)
        at com.informix.jdbc.IfxStatement.executeUpdateImpl(IfxStatement.java:850)
        at com.informix.jdbc.IfxPreparedStatement.executeUpdate(IfxPreparedStatement.java:281)
        at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:335)
        at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
        at net.sf.hibernate.collection.AbstractCollectionPersister.deleteRows(AbstractCollectionPersister.java:568)
        ... 59 more


Top
 Profile  
 
 Post subject: an amendment
PostPosted: Sat Jun 04, 2005 5:22 pm 
Newbie

Joined: Sat Jun 04, 2005 2:35 pm
Posts: 7
I discovered that although I was specifying that inverse="true" in XDoclet, it was not making it to the hbm.xml file. I since upgraded to XDoclet 1.2.3 and it is not propogating the inverse tag correclty, and the delete feature is also working correctly.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.