English 中文(简体)
Can 我向使用同样“实体类别”的JPA的不同喷气式数据库写信。
原标题:Can I write to different jetty databases using JPA that is using the same "entity class"
  • 时间:2010-06-11 08:39:46
  •  标签:
  • java
  • jpa

我正在使用Java persistance和实体Manager的班级,并负责储存一个将写给数据库的班级物体。 我的问题是,我想用同一个储存类别向不同的数据库书写。 我的解决方案是撰写一份储存手册,其中有一个包含所有实体管理者的地图。 在我研究数据库之前,解决办法是好的,并且认识到,所有信息(取决于地图,它具有正确的价值)都写给同一数据库(地图中首版)。

So my question is: Can I write to different databases using JPA that is using the same storage class (the class holding the structure of my database)?

增 编

最佳回答

我的解决方案是撰写一份储存手册,其中载有所有实体管理者的地图。

我不认为<代码>Map> 。

However, it should be possible to use Persistence.createEntityManagerFactory(String, Map) to create N EntityManagerFactory pointing to N databases (the mentioned factory method allows to pass additional properties that override values that may have been configured elsewhere, for example a connection url) and to these EntityManagerFactory in a Map.

然后,从(使用你想要的钥匙)上取得“右”<代码>。 实体管理/编码。

问题回答

是的,在<代码>persistence.xml中界定了多个持久性单位。 然后,在插入<条码>@PersistenceContext时。 具体列明<代码>unitName属性。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签