You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Patrick Linskey <pl...@gmail.com> on 2008/04/09 17:21:13 UTC
Re: svn commit: r646377 - /openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
Hi,
What is the impact of this change for the following pair of classes:
@Entity @NamedQuery(name="findAll", query="select item from
LineItem item")
public class LineItem { ... }
@Entity @NamedQuery(name="findAll", query="select p from Person p")
public class Person { ... }
The system should fail to parse that pair of classes. Do we have a
test case that asserts that that's the case? Also, why are we doubly-
parsing these named queries?
In other words, does this change just mask some larger problem?
-Patrick
On Apr 9, 2008, at 9:31 AM, allee8285@apache.org wrote:
> Author: allee8285
> Date: Wed Apr 9 07:31:30 2008
> New Revision: 646377
>
> URL: http://svn.apache.org/viewvc?rev=646377&view=rev
> Log:
> OPENJPA-565 - Ignore duplicate NamedQuery definition and continue to
> parse the remaining entries in NamedQueries definition.
>
> Modified:
> openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/
> apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
>
> Modified: openjpa/branches/1.0.x/openjpa-persistence/src/main/java/
> org/apache/openjpa/persistence/
> AnnotationPersistenceMetaDataParser.java
> URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=646377&r1=646376&r2=646377&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/
> apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
> (original)
> +++ openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/
> apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
> Wed Apr 9 07:31:30 2008
> @@ -1567,7 +1567,7 @@
> if (meta != null) {
> if (_log.isWarnEnabled())
> _log.warn(_loc.get("dup-query", query.name(),
> el));
> - return;
> + continue;
> }
>
> meta = getRepository().addQueryMetaData(null,
> query.name());
> @@ -1608,7 +1608,7 @@
> if (meta != null) {
> if (_log.isWarnEnabled())
> _log.warn(_loc.get("dup-query", query.name(),
> el));
> - return;
> + continue;
> }
>
> meta = getRepository().addQueryMetaData(null,
> query.name());
>
>
--
Patrick Linskey
202 669 5907
Re: svn commit: r646377 - /openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
Posted by Patrick Linskey <pl...@gmail.com>.
Cool, thanks for the details.
-Patrick
On Apr 9, 2008, at 10:48 AM, Albert Lee wrote:
> Patrick,
>
> The patch should not change the current behavior in your example.
>
> private void parseNamedQueries(AnnotatedElement el, NamedQuery...
> queries) {
> ..........
> meta = getRepository().getCachedQueryMetaData(null,
> query.name());
> if (meta != null) {
> if (_log.isWarnEnabled())
> _log.warn(_loc.get("dup-query", query.name(), el));
> // return;
> continue;
> }
> }
>
> If query.name() is found in the repository cache, the "before patch"
> behavior is posting a "ignore" warning message and stop parsing the
> remaining @NamedQuery in the queries input parameter. Basically it
> is an
> no-op. The "after patch" behavior remains the same for @NamedQuery,
> since
> there is only one entry in the queries list. The only change in
> behavior is
> for @NamedQueries. If a duplicate NameQuery is found, it used to stop
> parsing the remaining @NamedQuery. After the patch, it will ignore the
> duplicated entry and continue to parse the remaining entries in the
> queries
> input list.
>
> I am already working on a test case to cover this change.
>
> Albert Lee.
>
> On Wed, Apr 9, 2008 at 10:21 AM, Patrick Linskey
> <pl...@gmail.com> wrote:
>
>> Hi,
>>
>> What is the impact of this change for the following pair of classes:
>>
>> @Entity @NamedQuery(name="findAll", query="select item from
>> LineItem
>> item")
>> public class LineItem { ... }
>>
>> @Entity @NamedQuery(name="findAll", query="select p from Person p")
>> public class Person { ... }
>>
>> The system should fail to parse that pair of classes. Do we have a
>> test
>> case that asserts that that's the case? Also, why are we doubly-
>> parsing
>> these named queries?
>>
>> In other words, does this change just mask some larger problem?
>>
>> -Patrick
>>
>>
>> On Apr 9, 2008, at 9:31 AM, allee8285@apache.org wrote:
>>
>>> Author: allee8285
>>> Date: Wed Apr 9 07:31:30 2008
>>> New Revision: 646377
>>>
>>> URL: http://svn.apache.org/viewvc?rev=646377&view=rev
>>> Log:
>>> OPENJPA-565 - Ignore duplicate NamedQuery definition and continue to
>>> parse the remaining entries in NamedQueries definition.
>>>
>>> Modified:
>>>
>>> openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/
>>> apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
>>>
>>> Modified:
>>> openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/
>>> apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
>>> URL:
>>> http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=646377&r1=646376&r2=646377&view=diff
>>>
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> ---
>>> openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/
>>> apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
>>> (original)
>>> +++
>>> openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/
>>> apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
>>> Wed Apr 9 07:31:30 2008
>>> @@ -1567,7 +1567,7 @@
>>> if (meta != null) {
>>> if (_log.isWarnEnabled())
>>> _log.warn(_loc.get("dup-query", query.name(),
>>> el));
>>> - return;
>>> + continue;
>>> }
>>>
>>> meta = getRepository().addQueryMetaData(null,
>>> query.name());
>>> @@ -1608,7 +1608,7 @@
>>> if (meta != null) {
>>> if (_log.isWarnEnabled())
>>> _log.warn(_loc.get("dup-query", query.name(),
>>> el));
>>> - return;
>>> + continue;
>>> }
>>>
>>> meta = getRepository().addQueryMetaData(null,
>>> query.name());
>>>
>>>
>>>
>> --
>> Patrick Linskey
>> 202 669 5907
>>
>>
>>
>>
>>
>
>
> --
> Albert Lee.
--
Patrick Linskey
202 669 5907
Re: svn commit: r646377 - /openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
Posted by Albert Lee <al...@gmail.com>.
Patrick,
The patch should not change the current behavior in your example.
private void parseNamedQueries(AnnotatedElement el, NamedQuery...
queries) {
..........
meta = getRepository().getCachedQueryMetaData(null,
query.name());
if (meta != null) {
if (_log.isWarnEnabled())
_log.warn(_loc.get("dup-query", query.name(), el));
// return;
continue;
}
}
If query.name() is found in the repository cache, the "before patch"
behavior is posting a "ignore" warning message and stop parsing the
remaining @NamedQuery in the queries input parameter. Basically it is an
no-op. The "after patch" behavior remains the same for @NamedQuery, since
there is only one entry in the queries list. The only change in behavior is
for @NamedQueries. If a duplicate NameQuery is found, it used to stop
parsing the remaining @NamedQuery. After the patch, it will ignore the
duplicated entry and continue to parse the remaining entries in the queries
input list.
I am already working on a test case to cover this change.
Albert Lee.
On Wed, Apr 9, 2008 at 10:21 AM, Patrick Linskey <pl...@gmail.com> wrote:
> Hi,
>
> What is the impact of this change for the following pair of classes:
>
> @Entity @NamedQuery(name="findAll", query="select item from LineItem
> item")
> public class LineItem { ... }
>
> @Entity @NamedQuery(name="findAll", query="select p from Person p")
> public class Person { ... }
>
> The system should fail to parse that pair of classes. Do we have a test
> case that asserts that that's the case? Also, why are we doubly-parsing
> these named queries?
>
> In other words, does this change just mask some larger problem?
>
> -Patrick
>
>
> On Apr 9, 2008, at 9:31 AM, allee8285@apache.org wrote:
>
> > Author: allee8285
> > Date: Wed Apr 9 07:31:30 2008
> > New Revision: 646377
> >
> > URL: http://svn.apache.org/viewvc?rev=646377&view=rev
> > Log:
> > OPENJPA-565 - Ignore duplicate NamedQuery definition and continue to
> > parse the remaining entries in NamedQueries definition.
> >
> > Modified:
> >
> > openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
> >
> > Modified:
> > openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
> > URL:
> > http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=646377&r1=646376&r2=646377&view=diff
> >
> > ==============================================================================
> > ---
> > openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
> > (original)
> > +++
> > openjpa/branches/1.0.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
> > Wed Apr 9 07:31:30 2008
> > @@ -1567,7 +1567,7 @@
> > if (meta != null) {
> > if (_log.isWarnEnabled())
> > _log.warn(_loc.get("dup-query", query.name(), el));
> > - return;
> > + continue;
> > }
> >
> > meta = getRepository().addQueryMetaData(null, query.name());
> > @@ -1608,7 +1608,7 @@
> > if (meta != null) {
> > if (_log.isWarnEnabled())
> > _log.warn(_loc.get("dup-query", query.name(), el));
> > - return;
> > + continue;
> > }
> >
> > meta = getRepository().addQueryMetaData(null, query.name());
> >
> >
> >
> --
> Patrick Linskey
> 202 669 5907
>
>
>
>
>
--
Albert Lee.