openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kalpa Welivitigoda <callka...@gmail.com>
Subject Re: Create H2 database even before adding records
Date Thu, 24 Jul 2014 05:25:53 GMT
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 <curtisr7@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 <callkalpa@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 <curtisr7@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 <
> callkalpa@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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message