I am working on a web service based on Java EE, EJB, JSF and JPA. The service is provided to business customers, and the data stored for each customer is completely independent. What are the options for segmenting the data into different tables or databases, for each customer? E.g. there is an Account entity, and I want tables Account_customerA and Account_customerB, or different PostgreSQL databases*. The customer-ID will be determined from the subdomain or from a global user table.
Ideally we want to use the same EAR for all customers, for performance and maintenance reasons. As we are in the initial stages of the project, we are also interested in hearing options involving other frameworks like Spring.
*The rationale behind this request is one of security -- specifically to prevent mistakes that expose data between customers (so the best is to have different databases and/or database users). I also expect the lookup performance to be better with distinct tables / databases, though there will of course be a memory overhead.