Quantcast

No value specified for parameter 1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

No value specified for parameter 1

gullet
Hi all,

I have an issue with the error in my subject line above. The scenario is that I have some entries in a table (booking) and then I'm running through a file to make updates to the table rows.

If a booking exists than it can be changed (or deleted), if it doesn't, it can be inserted.

I'm testing the existence of a booking via an dependent association (film which the booking belongsTo) and a bookingNr (a reference number), but NOT the id (primary key). The id is unknown. The combination is unique, but the domain class and DB doesn't know it.

During the reading of the file lines, I can find the booking, I try to change a couple of properties and then save it. The save() fails. Grails starts by doing a get() on the id, before the save and I keep getting the error that the id parameter is not set.

The exception is: org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; "SELECT ......WHERE this_.id=** NOT SPECIFIED **". It's strange because the object to be saved contains the correct id.

Here is the booking class:

class Bokning implements Serializable {

    int bookingNo /* NOT unique by itself, but combined with the film instance below */

    java.sql.Date adDate
    java.sql.Date mediaDate

    java.sql.Date bookingDate
    java.sql.Date orderDate
    java.sql.Date playFrom
    java.sql.Date playTo

    Film film
    Order order

    static searchable = [only: ['bookingNo']]

    static hasOne = [order:Order]
    static belongsTo = [film:Film]

}

Details where the exception occurs during batch run:

def oldBooking = Booking.findByFilmAndBookingNo(film, bookingNo)

                    case '90': /* Code for changing an existing booking */
                        if (!oldBooking) {
                            /* Can't change a non-existent booking*/
                            errCode = 5
                        }
                        else {
                            /* All these properties are valid INCLUDING the id !!*/
                            println oldBooking.id
                            println oldBooking.film
                            println oldBooking.bio
                            println oldBooking.spelFrom
                            println oldBooking.spelTo
                           
                            oldBooking.spelFrom = spelFrom
                            oldBooking.spelTo = spelTo
                            oldBooking.andrad = now
                            oldBooking.andradAv = "Import"
                            if (!oldBooking.validate()) { /* validate() fails with the error */
                                println oldBooking.errors
                            }
                            else {
                                oldBooking.save(flush:true)
                            }
                        }
                        break


a) Do I need to state that the combination of bookingNo and film are unique?
b) The bookingNr have duplicates but not combined with the film instance
c) The retrieval of the oldBooking instance works fine and has all the properties of the entity


Any hints are really appreciated!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: No value specified for parameter 1

gullet
A little update to this:

I have found that the error occurs only when updating booking instances which has an order instance (from the order association).

For bidirectional hasOne-associations, I thought that the default cascade behaviour would be "ALL" (as it is for hasMany) for the owning side. Am I missing something or did I hit a bug? Do I need to change the cascade mapping to accomodate for this?

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: No value specified for parameter 1

Jeremy Bournesel
This post has NOT been accepted by the mailing list yet.
In reply to this post by gullet
Any update on this? I am hitting the exact same issue.

Thanks,
-J
Loading...