orm - Support JPA eclipselnk multi-tenancy -



orm - Support JPA eclipselnk multi-tenancy -

i have jpa application running, , want back upwards multi-tenancy. utilize xml instead of annotations.

i have couple of orm.xml referenced persistence.xml.

<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd" version="2.0"> <package>mypackage</package> <entity class="foo" /> <entity class="bar" /> </entity-mappings>

i utilize same multi-tenancy configuration entities: single-table, discriminator column tenantuserid, context-property tenant.userid.

according to: https://wiki.eclipse.org/eclipselink/examples/jpa/eclipselink-orm.xml

<tenant-discriminator-column name="tenantuserid" context-property="tenant.userid"/>

whether set line above? tried create eclipselink-orm.xml following

<?xml version="1.0" encoding="utf-8" ?> <entity-mappings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_1.xsd" version="2.1"> <tenant-discriminator-column name="tenantuserid" context-property="tenant.userid"/> <persistence-unit-metadata> <persistence-unit-defaults> <tenant-discriminator-column name="tenantuserid" context-property="tenant.userid"/> </persistence-unit-defaults> </persistence-unit-metadata> </entity-mappings>

both invalid according schema. set eclipselink-orm.xml?

is there way that: entities multi-tenant(single table)? have specify them entities 1 one?

<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd" version="2.0"> <package>mypackage</package> <entity class="foo" > <multi-tenant/> </entity> <entity class="bar" > <multi-tenant/> </entity> </entity-mappings>

thanks.

from http://www.eclipse.org/eclipselink/documentation/2.5/solutions/multitenancy002.htm using persistence unit default correctly as:

<persistence-unit-metadata> <persistence-unit-defaults> <tenant-discriminator-column name="tenantuserid" context-property="tenant.userid"/> </persistence-unit-defaults> </persistence-unit-metadata>

the problem using wrong schema version. 2.1 did not include multitenant features, need utilize 2.5 xds, eclipselink_orm_2_5.xsd. should in eclipselink.jar or pulled git james describes here http://git.eclipse.org/c/eclipselink/eclipselink.runtime.git/tree/jpa/org.eclipse.persistence.jpa/resource/org/eclipse/persistence/jpa

jpa orm eclipselink multi-tenant

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -