The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

I made a mistake. There is not createNativeQuery - there is createNamedQuery. Once I corrected the typo I was able to mock Query and EntityManager.
I'm trying to write a test to return a list from method calls to EntityManager. The line of code is:
entityManager.createNativeQuery("myQuery").setParameter(1, param1).getResultList()

Since createNativeQuery returns a Query, the setParameter is called on that. But so far I can't figure out how to set up the mocks to allow me to create a mocked Query that I can return my test list from when I call getResultList.

I've been looking at different syntax possibilities, but can't find a correct match. It would be easier if all the method calls were on entityManager and not on an object that it returns.

Forgot to mention that the error I keep getting when trying to mock this is "can't setParameter on null object".

In eBook version, Chapter 1, the binary search code just above the exercises has
mid = (low + high)
which is incorrect. It's missing the division by 2.
Thank you!
I've come across some Spock code that is of the form:
 with (object1, {
              member2 ==
              member3 ==

Here the with clause has an object followed by a comma before the opening brace. What is the difference, if any, of having a comma follow the object being evaluated?