src/main/resources/META-INF/persistence.xml dizinindedir
Örnek
Şöyle yaparız. jta-data-source ile JNDI ismi veriliyor.
<?xml version="1.0" encoding="UTF-8"?><persistence version="2.1"xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd "><persistence-unit name="MyAppPU" transaction-type="JTA"><jta-data-source>java:app/jdbc/MyApp</jta-data-source><shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode><properties><!-- JBoss Wildfly's Hibernate 4 specific JPA properties --><property name="hibernate.cache.use_second_level_cache" value="true" /><property name="hibernate.hbm2ddl.auto" value="validate" /><!-- NEVER: update --><property name="hibernate.show_sql" value="false" /><property name="hibernate.format_sql" value="false"/><property name="hibernate.use_sql_comments" value="false" /><property name="hibernate.enable_lazy_load_no_trans" value="true"/><!-- For Performance monitoring on Hibernate --><property name="hibernate.generate_statistics" value="false"/><property name="hibernate.cache.use_structured_entries" value="false"/><!-- TomEE PluME 1.7.2 and higher with EclipseLink --><property name="eclipselink.logging.logger" value="JavaLogger" /></properties></persistence-unit></persistence>
Kullanmak için şöyle yaparız
@PersistenceContext(unitName="MyAppPU") private EntityManager entityManager;
Hiç yorum yok:
Yorum Gönder