Announcement Announcement Module
Collapse
No announcement yet.
Why Hibernate and derby embedded not keep data Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why Hibernate and derby embedded not keep data

    I use spring roo version 1.1.0.RC1(in STS2.5.0.RC1) create project
    and use Hibernate and DERBY for persistence and Database.
    After create entity , controller and run application(use mvn jetty:run), I try to
    input some data but when i close jetty my input data was disappear.

    my persistence.xml

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence </provider>
    <properties>
    <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
    <!--value='create' to build a new database on each run; value='update' to modify an existing database; value='create-drop' means the same as 'create' but also drops tables when Hibernate closes; value='validate' makes no changes to the database-->
    <!--property name="hibernate.hbm2ddl.auto" value="validate"/-->
    <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
    </properties>
    </persistence-unit>
    </persistence>

    my database.properties

    database.password=sa
    database.url=jdbc\:derby\:SaleAppBackend
    database.username=sa
    database.driverClassName=org.apache.derby.jdbc.Emb eddedDriver

    my applicationContext.xml (Database Section)

    <bean class="org.apache.commons.dbcp.BasicDataSource" id="dataSource">
    <property name="driverClassName" value="${database.driverClassName}"/>
    <property name="url" value="${database.url}"/>
    <property name="username" value="${database.username}"/>
    <property name="password" value="${database.password}"/>
    </bean>
    <bean class="org.springframework.orm.jpa.JpaTransactionM anager" id="transactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>
    <tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
    <bean class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean" id="entityManagerFactory">
    <property name="dataSource" ref="dataSource"/>
    </bean>

    Any body help ?
Working...
X