是否有可能找到所有可用的EntityManager属性? [英] Is it possible to find all available EntityManager properties?

查看:275
本文介绍了是否有可能找到所有可用的EntityManager属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用乘法持久化单元具有不同特性(在我的情况下,MySQL和Oracle数据库)。在我的persistence.xml定义两个不同的持久化单元的S和只列出实体类在那里。

I need to use multiply persistence units with different properties (in my case MySQL and Oracle database). In persistence.xml I define two different "persistence-unit"s and list only the entity classes there.

属性可在persitence.xml设置与

Properties could be set in persitence.xml with

<性状>
      <属性名=...值=.../>
...

Im做它在一个Java类中创建的EntityManager之前,因为我必须使用不同的属性(我前仔细阅读):

Im doing it in a java class before creating the EntityManager, because I must use different properties (which I read before):

        EntityManagerFactory factory;
        ...
        HashMap<String, String> dbProperties = new HashMap<String, String>();
        dbProperties.put("javax.persistence.jdbc.driver", driver);
        dbProperties.put("javax.persistence.jdbc.url", url);
        dbProperties.put("javax.persistence.jdbc.user", user);
        dbProperties.put("javax.persistence.jdbc.password", password);
        dbProperties.put("eclipselink.ddl-generation", "none");
        dbProperties.put("eclipselink.ddl-generation.output-mode", "database");

        factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, dbProperties);
        EntityManager em = factory.createEntityManager();
        ...

对于Oracle我需要设置架构动态地(如果可能)和注解@Table不难codeD中的每个实体类。我猜会有我需要设置其他属性。所以我的问题是:有没有办法我可以找到了EntityManager

For Oracle I need to set Schema dynamicly (if possible) and not hardcoded in @Table annotation in each Entity class. And I guess there will be other properties I need to set. So my question is: is there a way I can find all avaible properties for the EntityManager?

推荐答案

您可以找到相应的JSR标准JPA属性。对于JPA 2.1(JSR 338),你会发现它们在文档的8.2.1.9章节。您也可以下载文件的。

You may find standard JPA properties on the corresponding JSR. For JPA 2.1 (JSR 338), you will find them on chapter 8.2.1.9 of the document. You can download the document there.

有关实施特定的属性,你会发现他们使用的执行文档上。对于的EclipseLink,这似乎是您正在使用的实现,你会发现他们的的。

For implementation specific properties, you may find them on the documentation of the implementation you use. For EclipseLink, which seems to be the implementation you are using, you will find them there.

这篇关于是否有可能找到所有可用的EntityManager属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆