Re: JPA doc related to EM Producer

2014-10-03 Thread hwaastad
Hi, DS doc specifies the use of BeanManagedUserTransactionStrategy in
beans.xml.

Should'nt that be enough?

..or containermanaged strategy?

br hw




--
View this message in context: 
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/JPA-doc-related-to-EM-Producer-tp4658999p4659081.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at 
Nabble.com.


Re: JPA doc related to EM Producer

2014-10-03 Thread Romain Manni-Bucau
IIRC with deltaspike you need a custom transaction strategy for JTA
(DS is really designed for resource local *by default*)


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-10-03 8:36 GMT+02:00 hwaastad :
> Hi,
> I've tried but realized an issue when using deltaspike and cdi injection in
> custom validators.
>
> the entity is flushed before validation is run and hence will fail.
>
> I made a test project on github
> (https://github.com/hwaastad/TomeeDsValidation.git) and u'll see that
> validation fails if the entitymanager is produced like this.
>
> br hw
>
>
>
> --
> View this message in context: 
> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/JPA-doc-related-to-EM-Producer-tp4658999p4659079.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at 
> Nabble.com.


Re: JPA doc related to EM Producer

2014-10-02 Thread hwaastad
Hi,
I've tried but realized an issue when using deltaspike and cdi injection in
custom validators.

the entity is flushed before validation is run and hence will fail.

I made a test project on github
(https://github.com/hwaastad/TomeeDsValidation.git) and u'll see that
validation fails if the entitymanager is produced like this.

br hw



--
View this message in context: 
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/JPA-doc-related-to-EM-Producer-tp4658999p4659079.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at 
Nabble.com.


Re: JPA doc related to EM Producer

2014-10-02 Thread Karl Kildén
Can you try this?

@PersistenceContext(unitName = APP_NAME)
private EntityManager entityManager;

@Produces
@RequestScoped
protected EntityManager createEntityManager() {
return this.entityManager;
}

On 3 October 2014 08:02, hwaastad  wrote:

> Hi,
> maybe a little late on this but I've been testing differet scenarios using
> tomee and deltaspike and using JTA these are the ones I found out working:
>
> @Produces
> @ApplicationScoped
> public EntityManagerFactory createEntityManagerFactory() {
> System.out.println("Producing EMF..");
> return Persistence.createEntityManagerFactory("ValidationPU");
> }
>
> @Produces
> public EntityManager createEntityManager(EntityManagerFactory
> entityManagerFactory) {
> System.out.println("Producing entitymanager.");
> return entityManagerFactory.createEntityManager();
> }
>
> with a little help from @romain i realized that my em's were resource_local
> using the producer shown in the DS docs.
>
> br hw
>
>
>
> --
> View this message in context:
> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/JPA-doc-related-to-EM-Producer-tp4658999p4659077.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>


Re: JPA doc related to EM Producer

2014-10-02 Thread hwaastad
Hi,
maybe a little late on this but I've been testing differet scenarios using
tomee and deltaspike and using JTA these are the ones I found out working:

@Produces
@ApplicationScoped
public EntityManagerFactory createEntityManagerFactory() {
System.out.println("Producing EMF..");
return Persistence.createEntityManagerFactory("ValidationPU");
}

@Produces
public EntityManager createEntityManager(EntityManagerFactory
entityManagerFactory) {
System.out.println("Producing entitymanager.");
return entityManagerFactory.createEntityManager();
}

with a little help from @romain i realized that my em's were resource_local
using the producer shown in the DS docs.

br hw



--
View this message in context: 
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/JPA-doc-related-to-EM-Producer-tp4658999p4659077.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at 
Nabble.com.


Re: JPA doc related to EM Producer

2014-09-26 Thread Gerhard Petracek
since we only provide documentation about deltaspike itself, it should be
clear implicitly.
some modules extend ee6/ee7 and therefore you will see a mix of java ee and
deltaspike by definition.
(BMT is a valid part of the spec. and therefore nothing special/separated.)

regards,
gerhard



2014-09-26 14:16 GMT+02:00 Claudio Miranda :

> On Thu, Sep 25, 2014 at 7:05 PM, Gerhard Petracek
>  wrote:
> >
> > please have a look at [1]. there you can see several differences compared
> > to your demo.
> > e.g. you don't have the TransactionalInterceptor in your beans.xml (see
> > [2]). if you would like to use jta, please have a look at [3].
>
>
> Hi Gerhard, the demo kitchenskink I did, doesn't use deltaspike, now I
> understand the jpa doc is related to the deltaspike @Transactional and
> not the JEE7 @Transactional. Now it makes sense to use
> @PersistenceUnit as the @Transactional interceptor needs BMT.
>
> Would it make sense to tell in the jpa doc that the @Transactional it
> refers is the deltaspike and not the JEE7 ?
>
> Thanks for your clarification.
>
> --
> clau...@claudius.com.br
> http://www.claudius.com.br
>


Re: JPA doc related to EM Producer

2014-09-26 Thread Claudio Miranda
On Thu, Sep 25, 2014 at 7:05 PM, Gerhard Petracek
 wrote:
>
> please have a look at [1]. there you can see several differences compared
> to your demo.
> e.g. you don't have the TransactionalInterceptor in your beans.xml (see
> [2]). if you would like to use jta, please have a look at [3].


Hi Gerhard, the demo kitchenskink I did, doesn't use deltaspike, now I
understand the jpa doc is related to the deltaspike @Transactional and
not the JEE7 @Transactional. Now it makes sense to use
@PersistenceUnit as the @Transactional interceptor needs BMT.

Would it make sense to tell in the jpa doc that the @Transactional it
refers is the deltaspike and not the JEE7 ?

Thanks for your clarification.

--
clau...@claudius.com.br
http://www.claudius.com.br


Re: JPA doc related to EM Producer

2014-09-25 Thread Gerhard Petracek
hi claudio,

please have a look at [1]. there you can see several differences compared
to your demo.
e.g. you don't have the TransactionalInterceptor in your beans.xml (see
[2]). if you would like to use jta, please have a look at [3].

regards,
gerhard

[1]
https://github.com/jboss-developer/jboss-wfk-quickstarts/blob/2.6.0.Final/kitchensink-deltaspike
[2] http://deltaspike.apache.org/documentation/jpa.html#__transactional
[3] http://deltaspike.apache.org/documentation/jpa.html#_jta_support



2014-09-24 10:39 GMT+02:00 Gerhard Petracek :

> thx for providing the demo-application which illustrates the issue. i'll
> have a look at it.
>
> regards,
> gerhard
>
>
>
> 2014-09-24 3:51 GMT+02:00 Claudio Miranda :
>
>> On Mon, Sep 22, 2014 at 5:36 PM, Gerhard Petracek
>>  wrote:
>> > that part of the documentation is based on demo-applications.
>> > if something doesn't work for you, please provide a link to
>> > a demo-application which illustrates the issue.
>>
>> See [1] for the demo application that reproduces the issue. There are
>> two applications based on kitchensink from wildfly quickstarts.
>> kitchensink-em uses the @PersistenceContext and the @Transactional works.
>> kitchensink-emf uses the @PersistenceUnit and the @Transactional doesn't
>> work.
>>
>> To reproduce, build them and deploy to wildfly 8.1, go to the
>> application and register a member, it the persist operation is
>> implemented in the MemberRegistration class.
>>
>> 1. https://www.dropbox.com/s/vid6s7vq2oqnx4g/deltaspike.zip?dl=0
>>
>> Kind regards
>> --
>>   Claudio Miranda
>>
>> clau...@claudius.com.br
>> http://www.claudius.com.br
>>
>
>


Re: JPA doc related to EM Producer

2014-09-24 Thread Gerhard Petracek
thx for providing the demo-application which illustrates the issue. i'll
have a look at it.

regards,
gerhard



2014-09-24 3:51 GMT+02:00 Claudio Miranda :

> On Mon, Sep 22, 2014 at 5:36 PM, Gerhard Petracek
>  wrote:
> > that part of the documentation is based on demo-applications.
> > if something doesn't work for you, please provide a link to
> > a demo-application which illustrates the issue.
>
> See [1] for the demo application that reproduces the issue. There are
> two applications based on kitchensink from wildfly quickstarts.
> kitchensink-em uses the @PersistenceContext and the @Transactional works.
> kitchensink-emf uses the @PersistenceUnit and the @Transactional doesn't
> work.
>
> To reproduce, build them and deploy to wildfly 8.1, go to the
> application and register a member, it the persist operation is
> implemented in the MemberRegistration class.
>
> 1. https://www.dropbox.com/s/vid6s7vq2oqnx4g/deltaspike.zip?dl=0
>
> Kind regards
> --
>   Claudio Miranda
>
> clau...@claudius.com.br
> http://www.claudius.com.br
>


Re: JPA doc related to EM Producer

2014-09-23 Thread Claudio Miranda
On Mon, Sep 22, 2014 at 5:36 PM, Gerhard Petracek
 wrote:
> that part of the documentation is based on demo-applications.
> if something doesn't work for you, please provide a link to
> a demo-application which illustrates the issue.

See [1] for the demo application that reproduces the issue. There are
two applications based on kitchensink from wildfly quickstarts.
kitchensink-em uses the @PersistenceContext and the @Transactional works.
kitchensink-emf uses the @PersistenceUnit and the @Transactional doesn't work.

To reproduce, build them and deploy to wildfly 8.1, go to the
application and register a member, it the persist operation is
implemented in the MemberRegistration class.

1. https://www.dropbox.com/s/vid6s7vq2oqnx4g/deltaspike.zip?dl=0

Kind regards
-- 
  Claudio Miranda

clau...@claudius.com.br
http://www.claudius.com.br


Re: JPA doc related to EM Producer

2014-09-22 Thread Gerhard Petracek
hi claudio,

the injected entity-manager is already a proxy -> you can expose it as it
is.

that part of the documentation is based on demo-applications.
if something doesn't work for you, please provide a link to
a demo-application which illustrates the issue.

regards,
gerhard



2014-09-22 22:24 GMT+02:00 Claudio Miranda :

> Hi, I was reading the jpa doc [1], and the recommendation to inject
> the @PersistenceUnit to create an EM to produce it, the @Transactional
> doesn't work, as the EM is BMT, the em.persist doesn't flush the
> entity to table.
>
> Also every emf.createEM invocation will create a new EM, looks like
> the right approach to produce an EM for EE server is the no EE-Server
> section.
>
> 1. deltaspike.apache.org/documentation/jpa.html
>
> --
>   Claudio Miranda
>
> clau...@claudius.com.br
> http://www.claudius.com.br
>


JPA doc related to EM Producer

2014-09-22 Thread Claudio Miranda
Hi, I was reading the jpa doc [1], and the recommendation to inject
the @PersistenceUnit to create an EM to produce it, the @Transactional
doesn't work, as the EM is BMT, the em.persist doesn't flush the
entity to table.

Also every emf.createEM invocation will create a new EM, looks like
the right approach to produce an EM for EE server is the no EE-Server
section.

1. deltaspike.apache.org/documentation/jpa.html

-- 
  Claudio Miranda

clau...@claudius.com.br
http://www.claudius.com.br