You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by daveor <do...@westglobal.com> on 2008/07/14 13:05:41 UTC

CXF Hibernate problem?

Hi all,

I really hope someone can help me with this. Using CXF as the basis for a
configuration repository. Configuration information is
marshalled/unmarshalled with JAXB and the service is using a JAXRS endpoint.

I'm writing a configuration front end and I'm having a problem when I'm
trying to save configurations
back to the registry.

Here is the endpoint code which I am invoking to update the configuration
(snippet):

@Path("/configResource")
public class ConfigResource {
    private ConfigDAO configDAO;

    @POST
    @Path("/configs")
    public void saveConfig(Config config) {
        configDAO.save(config);
    }
}

When this endpoint is invoked, the details of the config are successfully
posted to the service, unmarshalled and placed in the "config" variable.
However, I am unable to update an existing configuration. 

If I use saveOrUpdate() in the hibernate DAO as follows:

   public void save(Config config) {
        getHibernateTemplate().saveOrUpdate(config);
   }

I get the error:

INFO: Application has thrown exception, unwinding now:
org.springframework.orm.hibernate3.HibernateSystemException: reassociated
object has dirty collection reference (or an array); nested exception is
org.hibernate.HibernateException: reassociated object has dirty collection
reference (or an array)

This error appears to be caused when:

1) an attempt is made to reattach a detached object to a session and 
2) that object has references to collections of other objects and
3) the collection instance has been changed from the one that was returned
by hibernate (i.e. the collection is not an instance of
PersistentCollection)

I also tried using merge():

   public void save(Config config) {
        getHibernateTemplate().merge(config);
   }

which doesn't appear to do anything to the database either.

The DAO discussed here is based on
org.springframework.orm.hibernate3.support.HibernateDaoSupport.

I don't know whether this is related or not, but I was also receiving
LazyInitialization exceptions as described in CXF-1477, so my hbm file has
lazy="false" and cascade="all" on all collections.

Anything else....

Versions:

CXF 2.1
Hibernate 3.2.5

I've been at this for a solid week now and I'm really stuck, so any help
would be greatly appreciated. 

Thanks,
daveor



-- 
View this message in context: http://www.nabble.com/CXF-Hibernate-problem--tp18441302p18441302.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF Hibernate problem?

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

> 
> Hi all,
> 
> I really hope someone can help me with this. Using CXF as the basis for a
> configuration repository. Configuration information is
> marshalled/unmarshalled with JAXB and the service is using a JAXRS endpoint.
> 
> I'm writing a configuration front end and I'm having a problem when I'm
> trying to save configurations
> back to the registry.
> 
> Here is the endpoint code which I am invoking to update the configuration
> (snippet):
> 
> @Path("/configResource")
> public class ConfigResource {
>    private ConfigDAO configDAO;
> 
>    @POST
>    @Path("/configs")
>    public void saveConfig(Config config) {
>        configDAO.save(config);
>    }
> }
> 
> When this endpoint is invoked, the details of the config are successfully
> posted to the service, unmarshalled and placed in the "config" variable.
> However, I am unable to update an existing configuration. 


I wish I could help you but my Hibernate knowledge is, well, very limited :-)
You're saying that as far as JAX-Rs is concerned  everything works fine...

> 
> 1) an attempt is made to reattach a detached object to a session and 
> 2) that object has references to collections of other objects and
> 3) the collection instance has been changed from the one that was returned
> by hibernate (i.e. the collection is not an instance of
> PersistentCollection)

Can it be that Config instance 'meets' one of the above problem descriptions ?

It's likely that you'll get a better response on Hibernate-related forums...

Cheers, Sergey

> 
> I also tried using merge():
> 
>   public void save(Config config) {
>        getHibernateTemplate().merge(config);
>   }
> 
> which doesn't appear to do anything to the database either.
> 
> The DAO discussed here is based on
> org.springframework.orm.hibernate3.support.HibernateDaoSupport.
> 
> I don't know whether this is related or not, but I was also receiving
> LazyInitialization exceptions as described in CXF-1477, so my hbm file has
> lazy="false" and cascade="all" on all collections.
> 
> Anything else....
> 
> Versions:
> 
> CXF 2.1
> Hibernate 3.2.5
> 
> I've been at this for a solid week now and I'm really stuck, so any help
> would be greatly appreciated. 
> 
> Thanks,
> daveor
> 
> 
> 
> -- 
> View this message in context: http://www.nabble.com/CXF-Hibernate-problem--tp18441302p18441302.html
> Sent from the cxf-user mailing list archive at Nabble.com.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland