You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by Oliver Wulff <ow...@talend.com> on 2013/12/30 21:44:48 UTC

Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

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...



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?



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



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? But why did you use the JDBC template instead of the JPA layer?



Thanks a lot for your Feedback.



Oli

RE: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

Posted by Oliver Wulff <ow...@talend.com>.
>>>
This approach looks interesting, indeed: are you going to experiment
with it in Syncope trunk?
>>>
It should work in Syncope as it works in Fediz which has got a very similar set up. The only open question is dealing with the views as this would still require jdbc template.

Last but not least, you have to control in which order the entities are persisted due to dependencies. Of course, this can be improved to be configurable (which it is not in Fediz right now).

Thanks
Oli


________________________________________
From: Francesco Chicchiriccò [ilgrosso@apache.org]
Sent: 25 February 2014 09:32
To: dev@syncope.apache.org
Subject: Re: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

On 24/02/2014 21:13, Oliver Wulff wrote:
> Hi Francesco
>
>>>> 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).
>
> I decided to use the JPA Layer instead of JDBC Template to initially load the db
> https://issues.apache.org/jira/browse/FEDIZ-78
>
> But I don't have to write a ContextLoader then anymore as I can configure all the entity beans in an isolated spring configuration file, load it and call persist on all object types in a certain order:
> http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/DBLoaderSpring.java?view=markup
>
> Wouldn't that not make sense for Syncope as well?

This approach looks interesting, indeed: are you going to experiment
with it in Syncope trunk?

> The OpenJPA also supports to create the indexes - well in a proprietary way till JPA 2.1 is officially supported.

This is very interesting as well: upgrading to JPA 2.1 as soon as
OpenJPA supports it officially is definitely in our aims, I'd say.

Regards.

> ________________________________________
> From: Oliver Wulff [owulff@talend.com]
> Sent: 05 January 2014 14:44
> To: dev@syncope.apache.org
> Subject: RE: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml
>
>> OpenJPA is initialized via Spring in persistenceContextEMFactory.xml: as
> you can read from there, the OpenJpaVendorAdapter is configured with
> 'generateDdl' true.
>
> Even this was set to true (in my case for Fediz IDP) it didn't create the table therefore I thought there must be something else missing.
>
> Thanks
> Oli
>
> ________________________________________
> From: Francesco Chicchiriccò [ilgrosso@apache.org]
> Sent: 03 January 2014 14:06
> To: dev@syncope.apache.org
> Subject: Re: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml
>
> On 03/01/2014 13:56, Oliver Wulff wrote:
>> 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.
> OpenJPA is initialized via Spring in persistenceContextEMFactory.xml: as
> you can read from there, the OpenJpaVendorAdapter is configured with
> 'generateDdl' true.
>
>> 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.
> Good news: in case, please do it with reference to trunk (not 1_1_X branch).
>
> Regards.
>
>> ________________________________________
>> From: Francesco Chicchiriccò [ilgrosso@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/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PPMC
http://people.apache.org/~ilgrosso/


Re: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 24/02/2014 21:13, Oliver Wulff wrote:
> Hi Francesco
>
>>>> 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).
>
> I decided to use the JPA Layer instead of JDBC Template to initially load the db
> https://issues.apache.org/jira/browse/FEDIZ-78
>
> But I don't have to write a ContextLoader then anymore as I can configure all the entity beans in an isolated spring configuration file, load it and call persist on all object types in a certain order:
> http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/DBLoaderSpring.java?view=markup
>
> Wouldn't that not make sense for Syncope as well?

This approach looks interesting, indeed: are you going to experiment 
with it in Syncope trunk?

> The OpenJPA also supports to create the indexes - well in a proprietary way till JPA 2.1 is officially supported.

This is very interesting as well: upgrading to JPA 2.1 as soon as 
OpenJPA supports it officially is definitely in our aims, I'd say.

Regards.

> ________________________________________
> From: Oliver Wulff [owulff@talend.com]
> Sent: 05 January 2014 14:44
> To: dev@syncope.apache.org
> Subject: RE: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml
>
>> OpenJPA is initialized via Spring in persistenceContextEMFactory.xml: as
> you can read from there, the OpenJpaVendorAdapter is configured with
> 'generateDdl' true.
>
> Even this was set to true (in my case for Fediz IDP) it didn't create the table therefore I thought there must be something else missing.
>
> Thanks
> Oli
>
> ________________________________________
> From: Francesco Chicchiriccò [ilgrosso@apache.org]
> Sent: 03 January 2014 14:06
> To: dev@syncope.apache.org
> Subject: Re: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml
>
> On 03/01/2014 13:56, Oliver Wulff wrote:
>> 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.
> OpenJPA is initialized via Spring in persistenceContextEMFactory.xml: as
> you can read from there, the OpenJpaVendorAdapter is configured with
> 'generateDdl' true.
>
>> 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.
> Good news: in case, please do it with reference to trunk (not 1_1_X branch).
>
> Regards.
>
>> ________________________________________
>> From: Francesco Chicchiriccò [ilgrosso@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/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PPMC
http://people.apache.org/~ilgrosso/


RE: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

Posted by Oliver Wulff <ow...@talend.com>.
Hi Francesco

>>>
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).
>>>
I decided to use the JPA Layer instead of JDBC Template to initially load the db
https://issues.apache.org/jira/browse/FEDIZ-78

But I don't have to write a ContextLoader then anymore as I can configure all the entity beans in an isolated spring configuration file, load it and call persist on all object types in a certain order:
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/DBLoaderSpring.java?view=markup

Wouldn't that not make sense for Syncope as well?

The OpenJPA also supports to create the indexes - well in a proprietary way till JPA 2.1 is officially supported.

Thanks
Oli


________________________________________
From: Oliver Wulff [owulff@talend.com]
Sent: 05 January 2014 14:44
To: dev@syncope.apache.org
Subject: RE: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

> OpenJPA is initialized via Spring in persistenceContextEMFactory.xml: as
you can read from there, the OpenJpaVendorAdapter is configured with
'generateDdl' true.

Even this was set to true (in my case for Fediz IDP) it didn't create the table therefore I thought there must be something else missing.

Thanks
Oli

________________________________________
From: Francesco Chicchiriccò [ilgrosso@apache.org]
Sent: 03 January 2014 14:06
To: dev@syncope.apache.org
Subject: Re: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

On 03/01/2014 13:56, Oliver Wulff wrote:
> 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.

OpenJPA is initialized via Spring in persistenceContextEMFactory.xml: as
you can read from there, the OpenJpaVendorAdapter is configured with
'generateDdl' true.

> 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.

Good news: in case, please do it with reference to trunk (not 1_1_X branch).

Regards.

> ________________________________________
> From: Francesco Chicchiriccò [ilgrosso@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/


RE: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

Posted by Oliver Wulff <ow...@talend.com>.
> OpenJPA is initialized via Spring in persistenceContextEMFactory.xml: as
you can read from there, the OpenJpaVendorAdapter is configured with
'generateDdl' true.

Even this was set to true (in my case for Fediz IDP) it didn't create the table therefore I thought there must be something else missing.

Thanks
Oli

________________________________________
From: Francesco Chicchiriccò [ilgrosso@apache.org]
Sent: 03 January 2014 14:06
To: dev@syncope.apache.org
Subject: Re: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

On 03/01/2014 13:56, Oliver Wulff wrote:
> 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.

OpenJPA is initialized via Spring in persistenceContextEMFactory.xml: as
you can read from there, the OpenJpaVendorAdapter is configured with
'generateDdl' true.

> 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.

Good news: in case, please do it with reference to trunk (not 1_1_X branch).

Regards.

> ________________________________________
> From: Francesco Chicchiriccò [ilgrosso@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/


Re: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 03/01/2014 13:56, Oliver Wulff wrote:
> 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.

OpenJPA is initialized via Spring in persistenceContextEMFactory.xml: as 
you can read from there, the OpenJpaVendorAdapter is configured with 
'generateDdl' true.

> 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.

Good news: in case, please do it with reference to trunk (not 1_1_X branch).

Regards.

> ________________________________________
> From: Francesco Chicchiriccò [ilgrosso@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/


RE: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

Posted by Oliver Wulff <ow...@talend.com>.
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ò [ilgrosso@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/


Re: Persistence Layer in Syncope, Table Creation, orm.xml, content.xml

Posted by Francesco Chicchiriccò <il...@apache.org>.
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/