[jboss-user] [EJB 3.0] - Hypersonic data are all erased after jboss is restarted
peiguo
do-not-reply at jboss.com
Sun Apr 27 18:33:25 EDT 2008
The following code does persist data (orders and order lines) to database, and I did see that. The problem is that the data were all erased once jboss is restarted. How can I change that?
I have a persistencein META-INF directory:
| <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 http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
| <persistence-unit name="sample">
| <jta-data-source>java:/DefaultDS</jta-data-source>
| <properties>
| <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
| <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
| </properties>
| </persistence-unit>
| </persistence>
|
in my stateful bean I have this code, and checkout was called from outside:
|
| package org.jboss.tutorial.entity.bean;
|
| import javax.ejb.Remote;
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
| import javax.persistence.PersistenceContext;
|
|
| @Stateful
| @Remote(ShoppingCart.class)
| public class ShoppingCartBean implements ShoppingCart, java.io.Serializable
| {
| @PersistenceContext(unitName="sample")
| private EntityManager manager;
| private Order order;
|
| public void buy(String product, int quantity, double price)
| {
| if (order == null) order = new Order();
| order.addPurchase(product, quantity, price);
| }
|
| public Order getOrder()
| {
| return order;
| }
|
| @Remove
| public void checkout()
| {
| manager.persist(order);
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147091#4147091
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147091
More information about the jboss-user
mailing list