I am trying to develop a spring mvc based application in which my db structure has identical multiple tables bearing different names that relate to loggedin user's project (for operational reasons this is necessary). This way new tables get created and closed programmatically. Now how one can connect to multiple tables using the same model. For example:
@Entity
@Table(name="TABLE_X12")
public class User implements Serializable {
public static final long serialVersionUID = 1L;
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
@NotEmpty
@Column(name="id_key", unique=true, nullable=false)
private String id;
...
...
}
The table name "TABLE_X12" will be different for each logged-in user while the rest of the code and structure (like queries etc.) remain same.
Is it possible. I have done it in php because I simply get the applicable project name, generate the table name and query it accordingly.