본문 바로가기
프로그램/JPA

context-hibernate.xml

by cbwstar 2021. 7. 2.
728x90
반응형

주석으로 설명 달아 놓았습니다. 이해가 안가시는분은 댓글 달아 주세요.

was 에 따라서 멀티 db가 조금 꼬여서 톰캣서버에서는 잘되는데 jboss에서는 되긴 되는데 조금 db연결이 꼬여서 제외 했습니다. 멀티 db 마이바티스는 잘됩니다. jpa도 톰캣서버에서는 멀티 db 잘됩니다.

<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
	
	<!-- DB1 postgreSql 셋팅 컨테이너가 관리하는 EntityManager 생성, @PersistenceContext와 함께 사용 -->
 	<!--
	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" primary="true">
    -->
	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" >
		
		<!-- postgreSql -->
		<property name="dataSource" ref="egov.postgreDataSource" />
		<!-- entity 어노테이션 매핑정보 스캔 --> 
		<property name="packagesToScan" value="egovframework.invako.domain" /> 
		  
        <!-- 
        <property name="packagesToScan" value="egovframework.invako.postgre.domain" />  
        <property name="packagesToScan" value="egovframework" />
         --> 
             
		<!-- 구현체별 자체 기능을 표준화 -->
		<property name="jpaVendorAdapter">
			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
				<property name="showSql" value="true" />
				<property name="generateDdl" value="true" />
			</bean>
		</property>
		<!-- persistence.xml 설정정보와 함께 사용가능 --> 
	  
		<property name="persistenceUnitName" value="postgresqlPersistenceUnit" />

		<property name="jpaProperties">
			<props>
				<prop key="hibernate.naming.implicit-strategy">org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl</prop>
				<prop key="hibernate.naming.physical-strategy">org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl</prop>
				<prop key="hibernate.hbm2ddl.auto">none</prop>
				<!-- 
    			<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
    			-->
    			<prop key="hibernate.dialect">egovframework.invako.querydsl.config.CustomPostgreSQLDialect</prop>
				<prop key="hibernate.show_sql">true</prop>                
				<prop key="hibernate.format_sql">true</prop>                
				<prop key="hibernate.use_sql_comments">true</prop>         
				<prop key="hibernate.jdbc.batch_size">5</prop>
				<!-- 스키마설정 default:public -->
				<!-- 
				<prop key="hibernate.default_schema">${yourSchema}</prop>
				-->
			</props>
		</property>
				
		 <!-- 
		<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
		-->
		
	</bean> 
	 
	<!-- DB2 tibero 컨테이너가 관리하는 EntityManager 생성, @PersistenceContext와 함께 사용 -->
	<!-- tomcat 잘되는 jboss에는 멀티db셋팅시 영속성에 오류가 나서 제외함 -->
	<!-- 
	<bean id="entityManagerFactory2" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		
		<property name="dataSource" ref="egov.tiberoDataSource" /> 
		 
         <property name="packagesToScan" value="egovframework.invako.tibero.domain" />

		<property name="jpaVendorAdapter">
			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
				<property name="showSql" value="true" />
				<property name="generateDdl" value="true" />
			</bean>
		</property>
	  
		<property name="persistenceUnitName" value="tiberoPersistenceUnit" />
	
		<property name="jpaProperties">
			<props>
				<prop key="hibernate.naming.implicit-strategy">org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl</prop>
				<prop key="hibernate.naming.physical-strategy">org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl</prop>

				<prop key="hibernate.hbm2ddl.auto">none</prop>
				<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
				<prop key="hibernate.show_sql">true</prop>                
				<prop key="hibernate.format_sql">true</prop>                
				<prop key="hibernate.use_sql_comments">true</prop>         
				<prop key="hibernate.jdbc.batch_size">5</prop>
			</props>
		</property> 
		 
		<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
		
	</bean>
	-->

</beans>
728x90
반응형

'프로그램 > JPA' 카테고리의 다른 글

context-nexacro.xml  (0) 2021.07.02
context-mapper.xml  (0) 2021.07.02
context-jpa-repository.xml  (0) 2021.07.02
context-datasource.xml 설정 파일  (0) 2021.07.02
전자정부 소스 자동 생성 툴  (0) 2021.06.30

댓글



"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."

loading