点击这里给我发消息 点击这里给我发消息

Spring+JPA+MySQL的配置文件

添加时间:2013-12-7
    相关阅读: SQL

    一直在整合spring+hibernate,今天整合一下JPA +Spring

    persistence.xml 默认放在 META-INF 目录下

    Xml代码
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0">
    <persistence-unit name="java2000" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>MyClass</class>
    <properties>
    <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" />
    <property name="show_sql" value="true" />
    <property name="hibernate.cache.use_second_level_cache" value="true" />
    <property name="hibernate.cache.use_query_cache" value="false" />
    </properties>
    </persistence-unit>
    </persistence>
    view plaincopy to clipboardprint?
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0">
    <persistence-unit name="java2000" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>MyClass</class>
    <properties>
    <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" />
    <property name="show_sql" value="true" />
    <property name="hibernate.cache.use_second_level_cache" value="true" />
    <property name="hibernate.cache.use_query_cache" value="false" />
    </properties>
    </persistence-unit>
    </persistence>

    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0">
    <persistence-unit name="java2000" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>MyClass</class>
    <properties>
    <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" />
    <property name="show_sql" value="true" />
    <property name="hibernate.cache.use_second_level_cache" value="true" />
    <property name="hibernate.cache.use_query_cache" value="false" />
    </properties>
    </persistence-unit>
    </persistence>
     applicationContext.xml

 

[1] [2] 下一页

咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册