You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Enrico Olivelli <eo...@gmail.com> on 2012/08/27 08:06:05 UTC

Question on Persistence ref validation

I'm implementing https://issues.apache.org/jira/browse/OPENEJB-731
I'm adding it to:
org.apache.openejb.config.rules.CheckPersistenceRefs

but I think I need the real PersistenceUnit, what is the best way to get 
it ?

thanks
Enrico

Re: Question on Persistence ref validation

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Just saw it.

Seems almost perfect, just wonder is managedbean shouldnt be checked
(cdi)...or if we shouldnt save this scanning if not done to avoid a long
field browsing
Le 1 sept. 2012 16:27, "Enrico Olivelli" <eo...@gmail.com> a écrit :

> in the patch I attached a new test case in CheckPersistenceContextUsageTe*
> *st that uses that API
>
> Il 01/09/2012 16:25, Romain Manni-Bucau ha scritto:
>
>> Sounds not bad for me.
>>
>> Note: we have some cool api to test validations maybe you can enhance the
>> patch with such a test (rules package)
>> Le 1 sept. 2012 15:40, "Enrico Olivelli" <eo...@gmail.com> a écrit :
>>
>>  I attached a patch (code + test) for this issue
>>> https://issues.apache.org/****jira/browse/OPENEJB-731<https://issues.apache.org/**jira/browse/OPENEJB-731>
>>> <https:**//issues.apache.org/jira/**browse/OPENEJB-731<https://issues.apache.org/jira/browse/OPENEJB-731>
>>> >
>>>
>>> It recognizes the most common usecase I think
>>> @PersistenceContext(unitName='****someRESOURCE_LOCALunit" EntityManager)
>>>
>>> does it work ?
>>>
>>> - Enrico
>>>
>>>
>>> Il 28/08/2012 05:59, David Blevins ha scritto:
>>>
>>>  On Aug 26, 2012, at 11:06 PM, Enrico Olivelli wrote:
>>>>
>>>>   I'm implementing https://issues.apache.org/****
>>>> jira/browse/OPENEJB-731<https://issues.apache.org/**jira/browse/OPENEJB-731>
>>>> <https:**//issues.apache.org/jira/**browse/OPENEJB-731<https://issues.apache.org/jira/browse/OPENEJB-731>
>>>> >
>>>>
>>>>> I'm adding it to:
>>>>> org.apache.openejb.config.****rules.CheckPersistenceRefs
>>>>>
>>>>> but I think I need the real PersistenceUnit, what is the best way to
>>>>> get
>>>>> it ?
>>>>>
>>>>>  The persistence-unit definitions will be in the AppModule.**
>>>> getPersistenceModules();
>>>>
>>>> Be warned that the actual matching of persistence units to references
>>>> can
>>>> get a little complicated.  There is actually a lesser known and lesser
>>>> used
>>>> URI syntax for identifying a jar and a unit name.  So we'll either need
>>>> to
>>>> be ok with giving up if we are unable to resolve it, or to duplicate the
>>>> resolution logic.
>>>>
>>>> What check were you imagining?  There's a check we don't have about
>>>> making sure an @EntityManager reference doesn't point to an
>>>> RESOURCE_LOCAL
>>>> unit.  Would be great to get that check, such a common mistake.
>>>>
>>>> I did a whole section on it at JAXConf:
>>>>
>>>> http://svn.apache.org/repos/****asf/openejb/trunk/**<http://svn.apache.org/repos/**asf/openejb/trunk/**>
>>>> presentations/2012_JAXConf_****Tomcat_to_JavaEE_with_TomEE.****pdf<
>>>> http://svn.apache.org/**repos/asf/openejb/trunk/**
>>>> presentations/2012_JAXConf_**Tomcat_to_JavaEE_with_TomEE.**pdf<http://svn.apache.org/repos/asf/openejb/trunk/presentations/2012_JAXConf_Tomcat_to_JavaEE_with_TomEE.pdf>
>>>> >
>>>>
>>>>
>>>> -David
>>>>
>>>>
>>>>
>

Re: Question on Persistence ref validation

Posted by Enrico Olivelli <eo...@gmail.com>.
in the patch I attached a new test case in 
CheckPersistenceContextUsageTest that uses that API

Il 01/09/2012 16:25, Romain Manni-Bucau ha scritto:
> Sounds not bad for me.
>
> Note: we have some cool api to test validations maybe you can enhance the
> patch with such a test (rules package)
> Le 1 sept. 2012 15:40, "Enrico Olivelli" <eo...@gmail.com> a écrit :
>
>> I attached a patch (code + test) for this issue
>> https://issues.apache.org/**jira/browse/OPENEJB-731<https://issues.apache.org/jira/browse/OPENEJB-731>
>>
>> It recognizes the most common usecase I think
>> @PersistenceContext(unitName='**someRESOURCE_LOCALunit" EntityManager)
>>
>> does it work ?
>>
>> - Enrico
>>
>>
>> Il 28/08/2012 05:59, David Blevins ha scritto:
>>
>>> On Aug 26, 2012, at 11:06 PM, Enrico Olivelli wrote:
>>>
>>>   I'm implementing https://issues.apache.org/**jira/browse/OPENEJB-731<https://issues.apache.org/jira/browse/OPENEJB-731>
>>>> I'm adding it to:
>>>> org.apache.openejb.config.**rules.CheckPersistenceRefs
>>>>
>>>> but I think I need the real PersistenceUnit, what is the best way to get
>>>> it ?
>>>>
>>> The persistence-unit definitions will be in the AppModule.**
>>> getPersistenceModules();
>>>
>>> Be warned that the actual matching of persistence units to references can
>>> get a little complicated.  There is actually a lesser known and lesser used
>>> URI syntax for identifying a jar and a unit name.  So we'll either need to
>>> be ok with giving up if we are unable to resolve it, or to duplicate the
>>> resolution logic.
>>>
>>> What check were you imagining?  There's a check we don't have about
>>> making sure an @EntityManager reference doesn't point to an RESOURCE_LOCAL
>>> unit.  Would be great to get that check, such a common mistake.
>>>
>>> I did a whole section on it at JAXConf:
>>>
>>> http://svn.apache.org/repos/**asf/openejb/trunk/**
>>> presentations/2012_JAXConf_**Tomcat_to_JavaEE_with_TomEE.**pdf<http://svn.apache.org/repos/asf/openejb/trunk/presentations/2012_JAXConf_Tomcat_to_JavaEE_with_TomEE.pdf>
>>>
>>>
>>> -David
>>>
>>>


Re: Question on Persistence ref validation

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Sounds not bad for me.

Note: we have some cool api to test validations maybe you can enhance the
patch with such a test (rules package)
Le 1 sept. 2012 15:40, "Enrico Olivelli" <eo...@gmail.com> a écrit :

> I attached a patch (code + test) for this issue
> https://issues.apache.org/**jira/browse/OPENEJB-731<https://issues.apache.org/jira/browse/OPENEJB-731>
>
> It recognizes the most common usecase I think
> @PersistenceContext(unitName='**someRESOURCE_LOCALunit" EntityManager)
>
> does it work ?
>
> - Enrico
>
>
> Il 28/08/2012 05:59, David Blevins ha scritto:
>
>> On Aug 26, 2012, at 11:06 PM, Enrico Olivelli wrote:
>>
>>  I'm implementing https://issues.apache.org/**jira/browse/OPENEJB-731<https://issues.apache.org/jira/browse/OPENEJB-731>
>>> I'm adding it to:
>>> org.apache.openejb.config.**rules.CheckPersistenceRefs
>>>
>>> but I think I need the real PersistenceUnit, what is the best way to get
>>> it ?
>>>
>> The persistence-unit definitions will be in the AppModule.**
>> getPersistenceModules();
>>
>> Be warned that the actual matching of persistence units to references can
>> get a little complicated.  There is actually a lesser known and lesser used
>> URI syntax for identifying a jar and a unit name.  So we'll either need to
>> be ok with giving up if we are unable to resolve it, or to duplicate the
>> resolution logic.
>>
>> What check were you imagining?  There's a check we don't have about
>> making sure an @EntityManager reference doesn't point to an RESOURCE_LOCAL
>> unit.  Would be great to get that check, such a common mistake.
>>
>> I did a whole section on it at JAXConf:
>>
>> http://svn.apache.org/repos/**asf/openejb/trunk/**
>> presentations/2012_JAXConf_**Tomcat_to_JavaEE_with_TomEE.**pdf<http://svn.apache.org/repos/asf/openejb/trunk/presentations/2012_JAXConf_Tomcat_to_JavaEE_with_TomEE.pdf>
>>
>>
>> -David
>>
>>
>

Re: Question on Persistence ref validation

Posted by Enrico Olivelli <eo...@gmail.com>.
I attached a patch (code + test) for this issue
https://issues.apache.org/jira/browse/OPENEJB-731

It recognizes the most common usecase I think
@PersistenceContext(unitName='someRESOURCE_LOCALunit" EntityManager)

does it work ?

- Enrico


Il 28/08/2012 05:59, David Blevins ha scritto:
> On Aug 26, 2012, at 11:06 PM, Enrico Olivelli wrote:
>
>> I'm implementing https://issues.apache.org/jira/browse/OPENEJB-731
>> I'm adding it to:
>> org.apache.openejb.config.rules.CheckPersistenceRefs
>>
>> but I think I need the real PersistenceUnit, what is the best way to get it ?
> The persistence-unit definitions will be in the AppModule.getPersistenceModules();
>
> Be warned that the actual matching of persistence units to references can get a little complicated.  There is actually a lesser known and lesser used URI syntax for identifying a jar and a unit name.  So we'll either need to be ok with giving up if we are unable to resolve it, or to duplicate the resolution logic.
>
> What check were you imagining?  There's a check we don't have about making sure an @EntityManager reference doesn't point to an RESOURCE_LOCAL unit.  Would be great to get that check, such a common mistake.
>
> I did a whole section on it at JAXConf:
>
> http://svn.apache.org/repos/asf/openejb/trunk/presentations/2012_JAXConf_Tomcat_to_JavaEE_with_TomEE.pdf
>
>
> -David
>


Re: Question on Persistence ref validation

Posted by David Blevins <da...@gmail.com>.
On Aug 26, 2012, at 11:06 PM, Enrico Olivelli wrote:

> I'm implementing https://issues.apache.org/jira/browse/OPENEJB-731
> I'm adding it to:
> org.apache.openejb.config.rules.CheckPersistenceRefs
> 
> but I think I need the real PersistenceUnit, what is the best way to get it ?

The persistence-unit definitions will be in the AppModule.getPersistenceModules();

Be warned that the actual matching of persistence units to references can get a little complicated.  There is actually a lesser known and lesser used URI syntax for identifying a jar and a unit name.  So we'll either need to be ok with giving up if we are unable to resolve it, or to duplicate the resolution logic.

What check were you imagining?  There's a check we don't have about making sure an @EntityManager reference doesn't point to an RESOURCE_LOCAL unit.  Would be great to get that check, such a common mistake.

I did a whole section on it at JAXConf:

http://svn.apache.org/repos/asf/openejb/trunk/presentations/2012_JAXConf_Tomcat_to_JavaEE_with_TomEE.pdf


-David