@SequenceGenerator.schema in multitenancy JPA EclipseLink [message #1786181] |
Thu, 26 April 2018 14:29 |
dav div Messages: 3 Registered: April 2018 |
Junior Member |
|
|
hello,
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?
@Entity
@NamedQuery(name = "Ville.findAll", query = "SELECT v FROM Ville v")
@Multitenant(MultitenantType.TABLE_PER_TENANT)
@TenantTableDiscriminator(type=TenantTableDiscriminatorType.SCHEMA, contextProperty="tenant-id")
public class Ville implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@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 https://stackoverflow.com/questions/43677932/how-to-set-sequencegenerator-schema-in-multitenancy 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
|
|
|
Powered by
FUDForum. Page generated in 2.59369 seconds