0

I want to store my table in two different databases, (for example: HyperSQL and MYSQL), but I can't duplicate table annotation like this:

@Entity(name="users")
@Table(name = "users", schema = "Users@HyperSQL_pu")
@Table(name = "users", schema = "Users@Mysql_pu")
public class UserEntitie implements Serializable {}

Have any idea, how can I do this without duplicating my bean class

h.zak
  • 1,407
  • 5
  • 21
  • 40

1 Answers1

3

This is why some people have recommended not to put schema information into annotations. Use orm.xml to specify schema information (schema name, table name, column name etc), and have one orm.xml per datastore that the system is deployed to. Clearly this means one EntityManagerFactory per datastore; you cannot have one class persisted into multiple datastores with the same EntityManagerFactory

Using annotations you can only specify something once, and would have to manually edit java files to redeploy.

  • Maybe it's not possible to use orm.xml, because I'm working with kundera as a framework, not hibernate, look : https://github.com/impetus-opensource/Kundera/issues/276 – h.zak May 27 '16 at 10:02
  • 1
    If your JPA provider is claiming to be JPA compliant (which they do) then it should support orm.xml. Since your provider seemingly does not support orm.xml (basic capabilities) then it should remove all statements about being JPA compliant (so it does not waste users time). Perhaps tell them this. JPA has had orm.xml since JPA 1!! –  May 27 '16 at 10:05
  • @BillyFrost why don't you tell us. I am Kundera Developer. where did you read **compliant means "supporting all the features"**? Kundera saves users' time. Check it's [home page](https://github.com/impetus-opensource/Kundera), I guess you can clearly see number of Stargazers, watchers, etc. – Dev May 28 '16 at 14:49
  • @devツ Why don't you state CLEARLY on your projects website the features that are supported and those that aren't then the user can easily see whether their project will be totally portable to other jPA vendors? Why don't you tell your users why you haven't done that? –  Jun 03 '16 at 09:40
  • Good point Billy. we can add supported features list in the project wiki. – Dev Jun 03 '16 at 09:56
  • @devツthat would be a great addition –  Jun 03 '16 at 13:16