File attachments were not updated to grails 1.1.1 from grails 1.1-beta3

This is a pretty specific upgrade path, but this is what I'm on. I guess I tried to go to 1.1 too, and had the same problem, but not 100% sure.

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

I have a "broker" object that has a "logo" (defined as the image domain). Image and attachment (parent class) are executed according to the above url.

In brokerController I have 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
    }

      

"Logo" is the name of the uploaded file from the form. After this code, there is another standard CRILIL Grails code ( brokerUserInstance.properties=params

, brokerUserInstance.save()

etc.).

This works fine in 1.1-beta3. I can upload an image, it will be thumbnails and domain bound just fine (relationships are in place in the db, etc.). When I update the broker object without uploading a new image, the old one remains intact.

Moving on to grails 1.1.1, when I try to load 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 load the 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 can find quite a few 0s on this subject. Works fine in 1.1-beta3, but something changed (dramatically) in 1.1.1 (and probably 1.1 too).

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

Thanks:)

+1


a source to share





All Articles