Hi guys,

I'm tryin to get started with REST and JPA using TomEE Plus v1.5.1 and
Derby.
The REST part of it is all right, it's the JPA part that's drivin me nuts.

*Here are the Datasources defined in tomee.xml:*

<tomee>
...
<Resource id="test_ds" type="DataSource">
    JdbcDriver   org.apache.derby.jdbc.EmbeddedDriver
    JdbcUrl      jdbc:derby://localhost:1527/test_db;create=true
    JtaManaged   true
</Resource>
<Resource id="test_ds_unmanaged" type="DataSource">    
    JdbcDriver   org.apache.derby.jdbc.EmbeddedDriver
    JdbcUrl      jdbc:derby://localhost:1527/test_db;create=true
        JtaManaged       false
</Resource>
...
</tomee>

*The persistence.xml:*

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
        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_2_0.xsd";>

        <persistence-unit name="test_pu" transaction-type="JTA">
        
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
                <jta-data-source>test_ds</jta-data-source>
                <non-jta-data-source>test_ds_unmanaged</non-jta-data-source>
                <class>de.mdesign.hellorest.entity.HelloEntity</class>
                <properties>
                        <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" />
                </properties>
        </persistence-unit>

</persistence>

For the sake of completeness, here is the whole rest of the test webapp ...

*The entity class:*

@Entity
@Table(name = "HELLO_ENTITY")
@TableGenerator(name = "HelloEntityId", table = "ID_POOL", pkColumnName =
"GEN_KEY", valueColumnName = "GEN_VALUE", pkColumnValue = "HELLO_ENTITY_ID")
@NamedQueries({ @NamedQuery(name = "HelloEntity.findAll", query = "SELECT h
FROM HelloEntity h") })
public class HelloEntity implements Serializable {
        @Id
        @GeneratedValue(strategy = GenerationType.TABLE, generator =
"HelloEntityId")
        private Long id;
        @Column
        private String name;
...
}

*And finally the REST-Service:*

@Path("/rest")
@Produces({MediaType.TEXT_PLAIN})
public class HelloRest {
        @PersistenceContext(unitName = "test_pu")
        private EntityManager em;
        @PUT
        @Path("/create")
        public String createEntry(@QueryParam("name") String name) {
                HelloEntity hello = new HelloEntity();
                hello.setName(name);
                hello = em.merge(hello);
                return ("Hello "+hello.getName()+" (id="+hello.getId()+")");
        }
...
}

I get no errors or warnings or whatever on TomEE startup and webapp
deployment.
All datasources defined get created.
All entities are found.

What am I doin wrong ?




--
View this message in context: 
http://openejb.979440.n4.nabble.com/Derby-database-does-not-get-created-tp4661165.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to