Reputation: 1
I'm using Eclipselink with @Multitenant. everything is going well except for @SequenceGenerator
@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;
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
looks like sequence name doesn't follow by per schema naming convention, so on each tenant/schema system
How could I configure it with @Multitenant to look for the sequence in the active tenant shema?
in this topic 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.
Upvotes: 0
Views: 324