Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @SequenceGenerator.schema in multitenancy JPA EclipseLink
@SequenceGenerator.schema in multitenancy JPA EclipseLink [message #1786181] Thu, 26 April 2018 14:29
dav div is currently offline dav divFriend
Messages: 3
Registered: April 2018
Junior Member

I have a problem with The value for annotation attribute SequenceGenerator.schema:

if I do not specify it, it will look for it in the default schema and return an error because it does not find the sequence

How could I configure it with @Multitenant to look for the sequence in the active tenant shema?

@NamedQuery(name = "Ville.findAll", query = "SELECT v FROM Ville v")
@TenantTableDiscriminator(type=TenantTableDiscriminatorType.SCHEMA, contextProperty="tenant-id")
public class Ville implements Serializable {
    private static final long serialVersionUID = 1L;

@SequenceGenerator(name = "VILLE_IDVILLE_GENERATOR", sequenceName = "SEQ_ID_VILLE", allocationSize = 1, schema = ? )
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "VILLE_IDVILLE_GENERATOR")
private Integer idville;

looks like sequence name doesn't follow by per schema naming convention, so on each tenant/schema system

in this topic there is this :

the easy way that i find is to update schema to suit the current tenant at the beginning of every transaction SET search_path TO tenant! How can I do that ? I tried :

EntityManager.cretQuery("SET search_path TO tenant");

I get this erreur : The query does not start with a valid identifier, has to be either SELECT, UPDATE or DELETE FROM.

[Updated on: Thu, 26 April 2018 16:04]

Report message to a moderator

Previous Topic:Multi tenancy with schema per tenant
Next Topic:Multi tenancy with schema per tenant and ids by sequence
Goto Forum:

Current Time: Fri Jan 21 12:19:48 GMT 2022

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

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

Back to the top