I have many EntityManager
, one per schema that I have (I use entity-mappings
file to map EMs with schemas). It works.
When I use @Nam
Prefix your table name with "{h-schema}", e.g.SELECT foo FROM {h-schema}table
(courtesy of getting hibernate default schema name programmatically from session factory?)
Excerpts from documentation :
It isn't specified directly that NamedNativeQuery
is static, but both are same scoped & can't be altered afterwards & it's the desired behaviour.
Named queries are mean to be accessed by multiple modules - application wide, identified by unique name, so they are static & constant. You can try building a query string dynamically & can create a native query from it, instead of named native query.