- Spring ORM 教程
- Spring ORM - 主页
- Spring ORM - 概览
- Spring ORM - 环境设置
- Spring ORM & Hibernate
- Spring ORM - 创建项目
- Spring ORM - Maven Hibernate
- Spring ORM - Persistence Hibernate
- Spring ORM - 更新项目
- Spring ORM - 运行并测试 Hibernate
- Spring ORM & EclipseLink
- Spring ORM - Maven EclipseLink
- Spring ORM - Persistence EclipseLink
- Spring ORM - 更新 EclipseLink 项目
- Spring ORM - 运行并测试 EclipseLink
- Spring ORM 有用资源
- Spring ORM - 快速指南
- Spring ORM - 有用资源
- Spring ORM - 讨论
Spring ORM - 更新 EclipseLink 项目
现在,更新 AppConfig.java 以使用为 EclipseLink 创建的持久化单元。
AppConfig.java
package com.tutorialspoint.jpa; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScans; import org.springframework.context.annotation.Configuration; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.LocalEntityManagerFactoryBean; import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @EnableTransactionManagement @ComponentScans(value = { @ComponentScan("com.tutorialspoint.jpa.dao"), @ComponentScan("com.tutorialspoint.jpa.service") }) public class AppConfig { @Bean public LocalEntityManagerFactoryBean geEntityManagerFactoryBean() { LocalEntityManagerFactoryBean factoryBean = new LocalEntityManagerFactoryBean(); factoryBean.setPersistenceUnitName("EclipseLink_JPA"); return factoryBean; } @Bean public JpaTransactionManager geJpaTransactionManager() { JpaTransactionManager transactionManager = new JpaTransactionManager(); transactionManager.setEntityManagerFactory(geEntityManagerFactoryBean().getObject()); return transactionManager; } }
现在,重置数据库。
mysql> use tutorialspoint Database changed mysql> delete from employees; Query OK, 3 rows affected (0.02 sec) mysql> drop table employees; Query OK, 0 rows affected (0.17 sec) mysql>
广告