1

I have a query in a service method of a unit test that I'm calling lock true on, but every time I run the unit test with the lock true in, the unit test fails and gives the following error.

groovy.lang.MissingMethodException: No signature of method: com.myapp.foo.MyService.lock() is applicable for argument types: (java.lang.Boolean) values: [true]
Possible solutions: each(groovy.lang.Closure), wait(), grep(), find(), dump(), any()
    at com.myapp.foo.MyService.createShipment_closure22_closure79(MyService.groovy:1282)
    at com.myapp.foo.MyService.createShipment_closure22_closure79(MyService.groovy)
    at groovy.lang.Closure.call(Closure.java:411)
    at groovy.lang.Closure.call(Closure.java:405)
    at grails.gorm.CriteriaBuilder.invokeClosureNode(CriteriaBuilder.java:1093)
    at grails.gorm.CriteriaBuilder.get(CriteriaBuilder.java:257)
    at com.myapp.foo.MyService.createShipment_closure22(MyService.groovy:1277)
    at groovy.lang.Closure.call(Closure.java:411)
    at groovy.lang.Closure.call(Closure.java:427)
    at com.myapp.foo.MyService.createShipment(MyService.groovy:1274)
    at com.myapp.foo.MyServiceSpec.test create shipment: success(MyServiceSpec.groovy:124)

My query looks like this, and I know from prior, similar queries that it works in a real world scenario.

def shipmentInstance = Shipment.createCriteria().get {
    maxResults(1)
    eq("trackingNumber", shipment.trackingNumber.toString())

    lock true
}

Using Grails 2.3.11. I've confirmed in the docs that you can use lock true in a createCriteria().

RobStemen
  • 367
  • 1
  • 13

0 Answers0