|MongoDB and multi-tenancy [message #1385844]
||Wed, 11 June 2014 15:24
| GianMaria Romanato
Registered: July 2009
I am trying to use MongoDB via EclipseLink and to enable multi-tenant support.
I started from the EclipseLink Address/Customer/Order/OrderLine example which works fine with MongoDB, then I started adding the multi-tenant specific annotations.
In my first try I specified the annotations to use a discriminator column for holding the tenant-id, and this did not work and EclipseLink raises an exception claiming that the requested feature is not supported for NoSQL platforms.
I then reverted to the TABLE_PER_TENANT method of partitioning data, and this time the EntityManager is created and I am able to save orders to the database.
However, Multi-tenancy settings seem to be ignored, infact, the MongoDB for the Order entity is called ORDER and is not suffixed with the tenant identifier, as I would have expected given that the default behaviour for TABLE_PER_TENANT is to suffix the table name (at least according to the annotation javadoc).
public class Order implements Serializable
Here is the sample code I am using to try to insert data for two tenants:
Map properties = new HashMap();
EntityManagerFactory factory = Persistence.createEntityManagerFactory("mongo", properties);
EntityManager em = factory.createEntityManager(properties);
Order o1 = new Order();
I am calling the above code twice from a main, using different value for the tenantId variable, but the above results in two entries in the same collection named ORDER
I also tried forcing the tenant-id in the entity manager, both before and after opening the transaction (btw which is the correct way?) with no luck:
Can anyone give me some advice? Thanks
Developing for Virgo using PDE: http://bit.ly/1w0tTit
Global JNDI in Virgo: http://bit.ly/1to42mn
Hyperic to monitor Virgo: http://bit.ly/W1Fst9
Profile Virgo with JProfiler http://bit.ly/1FBLGCw
Powered by FUDForum
. Page generated in 0.03372 seconds