views:

352

answers:

0

This is a rather specific upgrade path, but it's what I'm on. I think I tried going to 1.1 as well, and had the same problem, but not 100% sure.

Anyway, I'm on 1.1-beta3 and have implemented a file upload/attachment system as outlined herer: thegioraproject.com/2008/03/26/image-attachments-in-grails-using-imagemagick/

I've got a 'broker' object which has a 'logo' (defined as an Image domain). The Image and Attachment (parent class) are done as defined in the above URL.

In the brokerController, I've got code like this:

    def file = new Image()
    def f = params.logo
    if(f.size>0) {
        file.setFile(f)
        file?.save(flush:true)
        brokerUserInstance.logo?.delete()
        brokerUserInstance.logo = file
    }

The 'logo' is the name of the uploaded file from the form. After this code there's more standard grails CRUD code (brokerUserInstance.properties=params, brokerUserInstance.save(), etc).

This works fine in 1.1-beta3. I can upload an image, it'll get thumbnailed and attached to the domain just fine (relations are in place in the db, etc). When I update the broker object without uploading a new image, the old one it kept intact.

Moving to grails 1.1.1, when I try to upload a new image, I get: Error 500: org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: Image; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: Image

and if I don't upload an image, I get: [org.springframework.web.multipart.commons.CommonsMultipartFile] to required type [Image] for property logo; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.web.multipart.commons.CommonsMultipartFile] to required type [Image] for property logo: no matching editors or conversion strategy found

I'm able to find pretty much 0 on this issue. Works fine in 1.1-beta3, but something's changed (dramatically) in 1.1.1 (and probably 1.1 as well).

Any suggestions/ideas/help? I'm happy to grant server access to someone to help debug this.

Thanks :)