Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] ManyToMany multitenant entities with regular entities

Hey Guy,

The full stack trace is here: https://gist.github.com/3920763

I'm setting the tenant.id when I ask for an EM in the Dao classes.

I haven't tried MultiTenant Users yet. I'll do that now.

Erik



On Fri, Oct 19, 2012 at 4:11 PM, Guy Pelletier <guy.pelletier@xxxxxxxxxx> wrote:
Erik,

When you say startup, do you mean at Entity Manager creation time? When do you set the tenant context?

Can you provide the full stack trace?

Out of curiosity, do you get past the error if User is set to be multitenant as well?

Thanks,
Guy

On 19/10/2012 3:29 PM, Erik Froese wrote:
Hey, I have a question about relationships between ManyToMany fields between two Entities. One is a MultiTenant Entity (one table per tentant) and the other is an Entity that should span all tenants. In this application we'll need to have Users that can switch between multiple tenants. Think of it like being on github.com when you "switch" organizations. So the User entity in this app should be just a normal JPA entity. The second entity is Award. Awards will have a Set<User> of investigators. In order to look up that list I'd like to be able to call theAward.getInvestigators() and get a set of User objects. I understand that querying the Awards a User is an investigator of is more complicated. It probably means opening up an EM for each of the user's tenancies and appending the Sets of awards together. I'm getting the following error on startup: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.IntegrityException|Descriptor Exceptions: |---------------------------------------------------------||Exception [EclipseLink-53] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.DescriptorException|Exception Description: The relation table name is not set for this mapping.|Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[awards]|Descriptor: RelationalDescriptor(com.rsmart.rfabric.model.User --> [DatabaseTable(USER)])||Runtime Exceptions: What table name should I be specifying? I think thee should be join table per tenant no? Code snippets below for the models. Thanks Erik @Entity public class User extends BaseEntity implements Serializable { ... private Set<Award> awards; @ManyToMany(mappedBy="investigators") public Set<Award> getAwards() { return awards; } public void setAwards(Set<Award> awards) { this.awards = awards; } } And Award @Entity @Multitenant(MultitenantType.
TABLE_PER_TENANT) public class Award extends BaseEntity { ... Set<User> investigators; @ManyToMany public Set<User> getInvestigators() { return investigators; } public void setInvestigators(Set<User> investigators) { this.investigators = investigators; } _______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users

--

Oracle
Guy Pelletier

ORACLE Canada, 45 O'Connor Street Suite 400 Ottawa, Ontario Canada K1P 1A4

Green
            Oracle Oracle is committed to developing practices and products that help protect the environment


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top