Thanks for your feedback. I didn't find where you configure OpenJPA to create 
the tables when the spring context is created. You do all the initialization 
work in SpringContextInitializer which also loads the table if empty.

I've used an ApplicationListener and used JPA to insert the records into the 
tables which will also create tables implicitly.

Will try to write a JPA based ContentLoader to fill the data.

Thanks
Oli

------

Oliver Wulff

Blog: http://owulff.blogspot.com
Solution Architect
http://coders.talend.com

Talend Application Integration Division http://www.talend.com

________________________________________
From: Francesco Chicchiriccò [ilgro...@apache.org]
Sent: 31 December 2013 09:14
To: dev@syncope.apache.org
Subject: Re: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

On 30/12/2013 21:44, Oliver Wulff wrote:
> Hi there
> I'm looking into adding a persistence layer to the Apache Fediz Identity 
> Provider and used the persistence layer in Syncope as a good reference. 
> Nevertheless, I got a few questions...

Hey, looks cool :-)

> 1) JPA creates the tables when the first entity is added - usually triggered 
> by a REST call.
> They won't be created when the spring application context is loaded. The 
> Syncope ContentLoader does only add rows to existing tables and creates 
> indexes and views, but no tables. How did you workaround this?

OpenJPA is configured in Syncope to create tables when Spring context is
loaded (you can experiment this by providing an empty content.xml or by
disabling the ContentLoader).

> 2) What was the reason for you to create an orm.xml instead of using 
> annotations only?

The general policy was to use orm.xml for all configurable parameters
that would have been instead stuck as annotation parameters in the
source code.
For example: putting table generators in orm.xml lets you easily
configure the initial value to pick without changing the source code.
This is very useful in Syncope since it is meant to be used via WAR
overlays.

> 3) You introduced your own semantic of a file to import default data 
> (content.xml). I assume you did not use an SQL script to be independent of 
> the database?

Correct.

> But why did you use the JDBC template instead of the JPA layer?

Hum, that's a nice question, probably related to the evolution that
ContentLoader had from original (pre-ASF) DBUnit.
I guess that one could rewrite ContentLoader, ContentUpgrader and
ContentExporter to work with EntityManager and thus remove spring-jdbc
from main dependencies (it will still be used by integration tests code).

Regards.

--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/

Reply via email to