Multitenant per table and native query [message #1811242] |
Thu, 29 August 2019 06:26  |
Eclipse User |
|
|
|
Hello
I'm using EclipseLink 2.6 with Multitenant setted to Tenant per table.
In my test, I found native queries like update and insert, runned by Query.executeUpdate(), working good by replacing table names in queries with table suffixed.
But native select queries, runned by Query.getSingleResult or Query.getResultList doesn't work: table names are not replaced.
EclipseLink documentation reports about "named native queries" are not supported; this made me think like all native queries are not supported, but update and insert made me believe!!
What's the real?
Thank a lot!
|
|
|
|
|
Re: Multitenant per table and native query [message #1822555 is a reply to message #1819141] |
Mon, 09 March 2020 14:48  |
Eclipse User |
|
|
|
Named queries in MT are processed against the uninitialized ServerSession, and so won't work with MT in its current form. I switched my named queries to all be created within the app to workaround the issue on my table/schema per tenant proof of concept work early on to workaround it.
I think I have some fixes locally to get things 'working', but I'm not sure how viable they are for the product as is - one of my changes was to modify AbstractSession so that getRootSession returns 'this'. A change that is fine for my project locally (or seems to be) as all descriptors are MT and should be using the leaf Session for queries, but not for the product overall. It might resolve the issue with named query processing, but I'm not confident in it - processing of them needs to be delayed until after the MT context is set, which might defeat the reusability of named queries overall anyway, so you are likely better with a workaround of creating them on demand for now.
If you have support contracts to leverage, please do, otherwise file bugs in EclipseLink's bug tracker with simple test cases and we can get votes (or even test partial solutions to see what they help with) to get it resolved.
Sorry.
|
|
|
Powered by
FUDForum. Page generated in 0.06103 seconds