It's apache-tomee-plus-1.6.0.2

I have my data source defined in context.xml and persistence.xml refers it
via JNDI.

I present you briefly with my setup hoping it will help you to figure out
what's wrong. I'll provide you with the source code if you want further
analysis.

I have the Order Entity. I have a separate class called OrderManager. It is
a stateful bean which has a EntityManager through @PersistenceContext (with
Extended as the persistence type). I have a servlet which processes the
requests and it has a EJB (EntityManager) injected.




On Thu, Jul 24, 2014 at 7:06 PM, Rick Curtis <curti...@gmail.com> wrote:

> Hrmm, odd. What version of TomEE are you using?
>
>
> On Thu, Jul 24, 2014 at 12:25 AM, Kalpa Welivitigoda <callka...@gmail.com>
> wrote:
>
> > Well it worked for me for some reason which I don't know. Yes your point
> is
> > valid, it is a JPA 2.1 property and OpenJPA support JPA 2.0.
> >
> > I observed the following,
> >
> > Without any property set in persistence.xml, if I restart TomEE it works
> as
> > expected. However when I tried again the same process, it doesn't work
> (it
> > complains that the table doesn't exist). It is strange. If I redeploy the
> > app (without any modifications) and try the functionality, it complains
> > that the table doesn't exist.
> >
> >
> >
> >
> > On Tue, Jul 22, 2014 at 6:37 PM, Rick Curtis <curti...@gmail.com> wrote:
> >
> > > > <property name="javax.persistence.schema-generation.database.action"
> > > value="drop-and-create"></property> entry in persistence.xml worked for
> > me.
> > >
> > > ... that doesn't make much sense to me. That property is a JPA 2.1 spec
> > > defined proeprty, and OpenJPA doesn't yet support that spec. Are you
> sure
> > > that you are really using OpenJPA? If you are using OpenJPA, I'm quite
> > > certain that the openjpa.jdbc.SynchronizeMapping property is doing all
> of
> > > the work.
> > >
> > > Thanks,
> > > Rick
> > >
> > >
> > >
> > > On Tue, Jul 22, 2014 at 12:11 AM, Kalpa Welivitigoda <
> > callka...@gmail.com>
> > > wrote:
> > >
> > > > <property name="javax.persistence.schema-generation.database.action"
> > > > value="drop-and-create"></property> entry in persistence.xml worked
> for
> > > me.
> > > > Since it is a in memory database and used temporary, dropping at the
> > end
> > > of
> > > > the application ok for me.
> > > >
> > > >
> > > > On Tue, Jul 22, 2014 at 12:40 AM, Rick Curtis <curti...@gmail.com>
> > > wrote:
> > > >
> > > > > The configuration(openjpa.jdbc.SynchronizeMapping) you have
> provided
> > > > should
> > > > > cause tables to be created the first time and EntityManager is
> > created.
> > > > >
> > > > > Thanks,
> > > > > Rick
> > > > >
> > > > >
> > > > > On Sun, Jul 20, 2014 at 1:14 PM, Kalpa Welivitigoda <
> > > callka...@gmail.com
> > > > >
> > > > > wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I am developing an application with H2 in memory database.
> > > > > >
> > > > > > The issue is that the table is created only after I add a record.
> > > > Before
> > > > > > that, if I search for a record it says that the table is not
> > found. I
> > > > > want
> > > > > > to create the table at the time the application starts rather
> than
> > > > > waiting
> > > > > > for a record to be added. Is there any property that serves this
> > > > > > requirement.
> > > > > >
> > > > > > Following is the content of persistence.xml,
> > > > > >
> > > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > > <persistence xmlns="http://java.sun.com/xml/ns/persistence";
> > > > > version="2.0">
> > > > > >     <persistence-unit name="rest-jpa">
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> > > > > >
> > <jta-data-source>java:/comp/env/jdbc/restDB</jta-data-source>
> > > > > >         <class>org.wso2.as.ee.Student</class>
> > > > > >         <properties>
> > > > > >             <property name="openjpa.jdbc.SynchronizeMappings"
> > > > > > value="buildSchema(ForeignKeys=true)"/>
> > > > > >         </properties>
> > > > > >     </persistence-unit>
> > > > > > </persistence>
> > > > > >
> > > > > > I have the datasource defined in context.xml as follows,
> > > > > >
> > > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > > <Context>
> > > > > >     <Resource
> > > > > >             name="jdbc/restDb"
> > > > > >             auth="Container"
> > > > > >             type="javax.sql.DataSource"
> > > > > >             driverClassName="org.h2.Driver"
> > > > > >             url="jdbc:h2:mem:restDb"
> > > > > >             username="admin"
> > > > > >             password="admin"
> > > > > >             JtaManaged="true" />
> > > > > > </Context>
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Best Regards,
> > > > > >
> > > > > > Kalpa Welivitigoda
> > > > > > +94776509215
> > > > > > http://about.me/callkalpa
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > *Rick Curtis*
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Best Regards,
> > > >
> > > > Kalpa Welivitigoda
> > > > +94776509215
> > > > http://about.me/callkalpa
> > > >
> > >
> > >
> > >
> > > --
> > > *Rick Curtis*
> > >
> >
> >
> >
> > --
> > Best Regards,
> >
> > Kalpa Welivitigoda
> > +94776509215
> > http://about.me/callkalpa
> >
>
>
>
> --
> *Rick Curtis*
>



-- 
Best Regards,

Kalpa Welivitigoda
+94776509215
http://about.me/callkalpa

Reply via email to