Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
- <context:annotation-config />
- <!-- Sesuaikan dengan nama package dao (data access object) yang telah dibuat atau mau dibuat -->
- <context:component-scan base-package="com.asm.dao" />
- <!-- Local Database -->
- <bean id="dsSPA" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="org.postgresql.Driver" />
- <property name="url" value="jdbc:postgresql://172.168.100.10:5436/db_SampleProjectSpringHibernate" />
- <property name="username" value="postgres"/>
- <property name="password" value="postgres"/>
- </bean>
- <bean id="entityManagerFactoryInternal" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="dsSPA"/>
- <property name="loadTimeWeaver">
- <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
- </property>
- <!-- Sesuaikan dengan nama package entity yang telah atau mau dibuat -->
- <property name="packagesToScan" value="com.asm.entity"/>
- <property name="jpaVendorAdapter">
- <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
- <property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect" />
- <!-- showsql = true sama dengan menampilkan sql atau query di log-->
- <property name="showSql" value="true" />
- <!-- generateddl= true sama dengan create tables and fields in database (syarat database sudah tersedia, otomatis generate tabel dan column)-->
- <property name="generateDdl" value="true" />
- </bean>
- </property>
- <property name="jpaProperties">
- <props>
- <prop key="hibernate.format_sql">true</prop>
- </props>
- </property>
- </bean>
- <!-- transactionManagerInternal biasa dipakai buat aksi simpan, ubah, hapus, cari dll
- contoh :
- @Transactional(value = "transactionManagerInternal")
- public void save(BusPendaftaran data) {
- em.persist(data);
- }
- @Transactional(value = "transactionManagerInternal")
- public void update(BusPendaftaran data) {
- em.merge(data);
- }
- -->
- <bean id="transactionManagerInternal" class="org.springframework.orm.jpa.JpaTransactionManager">
- <property name="entityManagerFactory" ref="entityManagerFactoryInternal"/>
- <property name="jpaDialect">
- <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
- </property>
- </bean>
- <!-- sharedEntityManagerInternal = (Resource / EntityManager)
- contoh :
- @Resource(name = "sharedEntityManagerInternal")
- private EntityManager em;
- -->
- <bean id="sharedEntityManagerInternal" name="sharedEntityManagerInternal" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
- <property name = "entityManagerFactory" ref="entityManagerFactoryInternal"/>
- </bean>
- <tx:annotation-driven transaction-manager="transactionManagerInternal" />
- </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement