Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Multitenant per table and native query
Multitenant per table and native query [message #1811242] Thu, 29 August 2019 10:26 Go to next message
Luca Pertile is currently offline Luca PertileFriend
Messages: 1
Registered: August 2019
Junior Member
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 #1818973 is a reply to message #1811242] Fri, 03 January 2020 19:27 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1339
Registered: July 2009
Senior Member
Can you elaborate, maybe add an example, of what you mean when you say "native queries"? Native queries in JPA refer to user defined SQL queries - something that won't work in table per tenant multi tenant environments as EclipseLink doesn't touch or change that SQL in anyway so wouldn't do any table name replacement. Could you have meant a named query instead of a native query?

MT has some quirks and vaguely remember some issues with per table MT that had me remove named queries, but not the specifics - it was a proof of concept and management went in a different non-MT direction. You might want to provide the exact details of what you have configured and file a bug to have the behaviour fixed.

[Updated on: Fri, 03 January 2020 19:28]

Report message to a moderator

Re: Multitenant per table and native query [message #1819141 is a reply to message #1818973] Wed, 08 January 2020 17:13 Go to previous message
Kevin Ng is currently offline Kevin NgFriend
Messages: 1
Registered: January 2020
Junior Member
Chris,

The multi tenancy feature in eclipselink is also causing me problems for native queries.

Before the entity was modifed with @Multitenant annotation, native query worked.

After adding:
@Multitenant(MultitenantType.TABLE_PER_TENANT)
@TenantTableDiscriminator(type = SCHEMA, contextProperty = MULTITENANT_PROPERTY_DEFAULT)

the native queries are giving the following error:

Caused by: java.lang.NullPointerException: null
at org.eclipse.persistence.internal.helper.NonSynchronizedVector.addAll(NonSynchronizedVector.java:315) ~[org.eclipse.persistence.core-2.7.5.jar!/:na]
at org.eclipse.persistence.queries.ObjectLevelReadQuery.getSelectionFields(ObjectLevelReadQuery.java:1808) ~[org.eclipse.persistence.core-2.7.5.jar!/:na]
at org.eclipse.persistence.internal.queries.CallQueryMechanism.prepareSelectAllRows(CallQueryMechanism.java:308) ~[org.eclipse.persistence.core-2.7.5.jar!/:na]
at org.eclipse.persistence.queries.ReadAllQuery.prepareSelectAllRows(ReadAllQuery.java:910) ~[org.eclipse.persistence.core-2.7.5.jar!/:na]
at org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:841) ~[org.eclipse.persistence.core-2.7.5.jar!/:na]
at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:673) ~[org.eclipse.persistence.core-2.7.5.jar!/:na]

Any suggestions or workaround appreciated!

Thanks

Kevin
Previous Topic:Zombie Entities? Constraint violation when modifying removed Entity
Next Topic:NPE on a JPQL query with NULL arg: bug?
Goto Forum:
  


Current Time: Thu Feb 27 21:06:13 GMT 2020

Powered by FUDForum. Page generated in 0.02014 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top