- Spring ORM 教程
- Spring ORM - 主页
- Spring ORM - 概述
- Spring ORM - 环境设置
- Spring ORM 和 Hibernate
- Spring ORM - 创建项目
- Spring ORM - Maven Hibernate
- Spring ORM - 持久化 Hibernate
- Spring ORM - 更新项目
- Spring ORM - 运行和测试 Hibernate
- Spring ORM 和 EclipseLink
- Spring ORM - Maven EclipseLink
- Spring ORM - 持久性 EclipseLink
- Spring ORM - 更新项目 EclipseLink
- Spring ORM - 运行和测试 EclipseLink
- Spring ORM 有用资源
- Spring ORM - 快速指南
- Spring ORM - 有用的资源
- Spring ORM - 讨论
Spring ORM - 更新项目 EclipseLink
现在更新 AppConfig.java 以使用为 EclipseLink 创建的持久性单元。
应用程序配置.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>