Named query does not default to project's default connection

We are attempting to determine whether or not a named query from a parent project will use the default connection of the parent project or the default project, but found that if the named query’s connection is set to < Default >, it won’t even use the current project’s default database connection. Instead, we see:

java.lang.IllegalArgumentException: Cannot find database connection - name cannot be null.

Might the child project’s named queries (defined in the child project) when set to < Default > actually depend on the parent project’s default database (which we set to < None > for test purposes) instead of their own project’s default connection?

Detail:
[Parent_Project]
- Default connection < None >
- Named query “NQ1”
- Connection < Default >
- Named query “NQ2”
- Connection “Parent DB Connection”

[Child_Project]
- Default connection “Child DB Connection”
- Named query “NQ3”
- Connection < Default >
- Named query “NQ4”
- Connection “Child DB Connection”

When running the child project, we would expect:
NQ1 to fail on no defined connection or to succeed on “Child DB Connection” (The purpose of the test was to determine this behavior)
NQ2 to succeed on “Parent DB Connection”
NQ3 to succeed on “Child DB Connection” (This failed unexpectedly)
NQ4 to succeed on “Child DB Connection”

When I have a Child Project with a configured default DB ‘QADB’, and I have a Named Query which uses the <Default> Database Connection, queries executed against the <Default> connection encounter no problems.

Please try the following:

  1. Close Designer.
  2. In Gateway, configure project to use preferred DB, and verify changes are saved.
  3. Open Designer.
  4. Attempt to run offending query again.
3 Likes

A couple of items for clarification for future readers:

  1. The project’s default connection appears to be cached with the session. i.e. you have to close all the browser tabs and re-establish a new session to see the changes.
  2. The parent’s default connection is not inherited. The derived project must set the default connection for any of the named queries that are set to <Default> to work.

In my earlier tests, I most likely did not refresh either the designer or the client in my testing, and had misleading results.

1 Like