AnsweredAssumed Answered

Create/Reuse a node

Question asked by swithun on Oct 14, 2010
Latest reply on Oct 27, 2010 by swithun
I'm having difficulty writing to the content of a node, if the node already exists. I have an action which tries create a node and write some content to it based on the node on which the action is run. This is fine if a node with the given name doesn't already exist. But if such a node already exists, because the same action has already been run on the original node, then I run into problems.

The code is a bit like this:

    fileRef = fileFolderService.create(dirRef, fileName, PROP_QNAME_CONTENT).getNodeRef();
catch (FileExistsException ffe)
    // what should go here?
ContentWriter writer = contentService.getWriter(fileRef, ContentModel.PROP_CONTENT, true);

I've tried to get a nodeRef for the node in various ways, and tried deleting it and then creating it again. Nothing gives me a usable nodeRef that I can use with getWriter. I always get a very long and unhelpful stack trace:

09:41:43,619 User:admin ERROR [org.hibernate.AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: null id in org.alfresco.repo.domain.hibernate.ChildAssocImpl entry (don't flush the Session after an exception occurs)
        at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(
        at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(
        at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(
        at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(
        at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(
        at org.hibernate.impl.SessionImpl.flush(
        at org.alfresco.repo.domain.hibernate.DirtySessionMethodInterceptor.flushSession(
        at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl$SessionFlusher.doInHibernate(
        at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(
        at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.addNodePropertyImpl(
        at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.addNodeProperty(

Has anyone faced and solved a similar problem?