jpa multi datasource
来源:互联网 发布:h5穿上军装源码 编辑:程序博客网 时间:2024/06/05 17:33
<persistence-unit name="com.demo" > <mapping-file>META-INF/orm.xml</mapping-file> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> <property name="hibernate.hbm2ddl.auto" value="validation" /> <property name="hibernate.format_sql" value="true"/> <property name="hibernate.show_sql" value="false"/> </properties> </persistence-unit>
<bean id="emfDemo"class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"><property name="dataSource" ref="dataSourceDemo" /><property name="jpaVendorAdapter"><bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"><property name="generateDdl" value="true" /> <property name="showSql" value="false" /> </bean></property><property name="loadTimeWeaver"><beanclass="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /></property><property name="persistenceUnitName" value="com.demo" /></bean>
<filter-mapping><filter-name>OpenEntityManagerInViewFilter1</filter-name><url-pattern>/*</url-pattern></filter-mapping><filter><filter-name>OpenEntityManagerInViewFilter2</filter-name><filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class><init-param><param-name>entityManagerFactoryBeanName</param-name><param-value>emfDemo</param-value></init-param></filter>
@PersistenceContext(unitName="emfDemo")public EntityManager entityManager;
@GET@Path("/jpa/test")@Transactionalpublic Response testJpaDemo(@QueryParam ("type") String type){this.getService().getDao().findAll();News news = this.getService().getDao().findOne(1L);News newsMaster = (News) entityManager.find(News.class,2L);logger.debug(news.getContent());logger.debug(newsMaster.getContent());News entity = new News();entity.setContent("main");this.getService().getDao().saveAndFlush(entity);News entityMaster = new News();entity.setContent("master");entityManager.persist(entityMaster);if(true)throw new GeneralException("", "test transaction");return Response.ok().build();}
0 0
- jpa multi datasource
- jboss 7 ejb jpa jms datasource配置
- Multi-Column Join in Hibernate/JPA Annotations
- spring-boot-multi-datasource(spring-boot多路数据源)
- was下jpa配置多个数据源 more datasource
- DataSource
- DataSource
- datasource
- dataSource
- dataSource
- multi-
- JPA
- JPA
- JPA
- JPA
- JPA
- JPA
- JPA
- UVa 1584 - Circular Sequence
- LeakTracer-内存泄露检测工具
- opencv中实现滚动条随着视频播放移动
- Servlet生命周期与工作原理
- 黑马程序员一分类,类的本质,description,SEL
- jpa multi datasource
- Linux查看内存使用量和交换区使用量
- 作用域生命周期
- CSS鼠标滑过改变样式颜色
- 操作系统进程线程总结
- poj 2762 Going from u to v or from v to u?
- 关于Maven仓库的本地位置配置
- 处理hash冲突的常见办法
- LinkedList