You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Tan bupt <de...@gmail.com> on 2009/02/25 05:38:49 UTC

bug: selectDistinct(List items) in apache-openjpa-2.0.0-SNAPSHOT

I think it is a bug in
org.apache.openjpa.persistence.query.QueryDefinitionImpl, can we fix it?

 public QueryDefinition selectDistinct(SelectItem... items) {
  return select(items == null ? null : Arrays.asList(items), true);
 }
 public QueryDefinition selectDistinct(List<SelectItem> items) {
  return select(items, false);
 }

 private QueryDefinition select(List<SelectItem> items, boolean isDistinct)
{
  if (_projections == null) {
   _projections = new ArrayList<SelectItem>();
  } else {
   _projections.clear();
  }
  _distinct = isDistinct;
  for (SelectItem item : items)
   _projections.add(item);
  return this;
 }

Re: bug: selectDistinct(List items) in apache-openjpa-2.0.0-SNAPSHOT

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
  Thanks.
   done...

$ svn commit -m "Oversight in QueryDefinition.selectDistinct() boolean
argument corrected"
openjpa-persistence\src\main\java\org\apache\openjpa\persistence\query\QueryDefinitionImpl.java
Committed revision 747848.




Tan Shuai wrote:
> 
>>
>> I think it is a bug in
>> org.apache.openjpa.persistence.query.QueryDefinitionImpl, can we fix it?
>>
>>  public QueryDefinition selectDistinct(SelectItem... items) {
>>   return select(items == null ? null : Arrays.asList(items), true);
>>  }
>>  public QueryDefinition selectDistinct(List<SelectItem> items) {
>>   return select(items, false);
>>  }
>>
>>  private QueryDefinition select(List<SelectItem> items, boolean
>> isDistinct)
>> {
>>   if (_projections == null) {
>>    _projections = new ArrayList<SelectItem>();
>>   } else {
>>    _projections.clear();
>>   }
>>   _distinct = isDistinct;
>>   for (SelectItem item : items)
>>    _projections.add(item);
>>   return this;
>>  }
>>
> 
> 

-- 
View this message in context: http://n2.nabble.com/Re%3A-bug%3A-selectDistinct%28List%3CSelectItem%3E-items%29-in--apache-openjpa-2.0.0-SNAPSHOT-tp2382144p2384626.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: bug: selectDistinct(List items) in apache-openjpa-2.0.0-SNAPSHOT

Posted by Tan bupt <de...@gmail.com>.
>
> I think it is a bug in
> org.apache.openjpa.persistence.query.QueryDefinitionImpl, can we fix it?
>
>  public QueryDefinition selectDistinct(SelectItem... items) {
>   return select(items == null ? null : Arrays.asList(items), true);
>  }
>  public QueryDefinition selectDistinct(List<SelectItem> items) {
>   return select(items, false);
>  }
>
>  private QueryDefinition select(List<SelectItem> items, boolean isDistinct)
> {
>   if (_projections == null) {
>    _projections = new ArrayList<SelectItem>();
>   } else {
>    _projections.clear();
>   }
>   _distinct = isDistinct;
>   for (SelectItem item : items)
>    _projections.add(item);
>   return this;
>  }
>

Re: bug: selectDistinct(List items) in apache-openjpa-2.0.0-SNAPSHOT

Posted by Pinaki Poddar <pp...@apache.org>.
This has been completed yesterday [1].
Direct commit because this code is going to be deprecated/removed in near
future.

[1]
http://n2.nabble.com/svn-commit%3A-r747848----openjpa-trunk-openjpa-persistence-src-main-java-org-apache-openjpa-persistence-query-QueryDefinitionImpl.java-tc2384621.html


Donald Woods wrote:
> 
> Are you proposing the following change?
> 
>   public QueryDefinition selectDistinct(List<SelectItem> items) {
> -  return select(items, false);
> +  return select(items, true);
>   }
> 
> Please open a JIRA so we can check in the fix and consider if we need a 
> new junit testcase to cover this.
> 
> Thanks.
> -Donald
> 
> Tan bupt wrote:
>> I think it is a bug in
>> org.apache.openjpa.persistence.query.QueryDefinitionImpl, can we fix it?
>> 
>>  public QueryDefinition selectDistinct(SelectItem... items) {
>>   return select(items == null ? null : Arrays.asList(items), true);
>>  }
>>  public QueryDefinition selectDistinct(List<SelectItem> items) {
>>   return select(items, false);
>>  }
>> 
>>  private QueryDefinition select(List<SelectItem> items, boolean
>> isDistinct)
>> {
>>   if (_projections == null) {
>>    _projections = new ArrayList<SelectItem>();
>>   } else {
>>    _projections.clear();
>>   }
>>   _distinct = isDistinct;
>>   for (SelectItem item : items)
>>    _projections.add(item);
>>   return this;
>>  }
>> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/bug%3A-selectDistinct%28List%3CSelectItem%3E-items%29-in-apache-openjpa-2.0.0-SNAPSHOT-tp2382071p2390821.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


Re: bug: selectDistinct(List items) in apache-openjpa-2.0.0-SNAPSHOT

Posted by Donald Woods <dw...@apache.org>.
Are you proposing the following change?

  public QueryDefinition selectDistinct(List<SelectItem> items) {
-  return select(items, false);
+  return select(items, true);
  }

Please open a JIRA so we can check in the fix and consider if we need a 
new junit testcase to cover this.

Thanks.
-Donald

Tan bupt wrote:
> I think it is a bug in
> org.apache.openjpa.persistence.query.QueryDefinitionImpl, can we fix it?
> 
>  public QueryDefinition selectDistinct(SelectItem... items) {
>   return select(items == null ? null : Arrays.asList(items), true);
>  }
>  public QueryDefinition selectDistinct(List<SelectItem> items) {
>   return select(items, false);
>  }
> 
>  private QueryDefinition select(List<SelectItem> items, boolean isDistinct)
> {
>   if (_projections == null) {
>    _projections = new ArrayList<SelectItem>();
>   } else {
>    _projections.clear();
>   }
>   _distinct = isDistinct;
>   for (SelectItem item : items)
>    _projections.add(item);
>   return this;
>  }
>