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*

Reply via email to