Allow adding the distinct functionality in OCL queries
------------------------------------------------------

         Key: OCL-20
         URL: http://jira.andromda.org/browse/OCL-20
     Project: OCL Translation
        Type: Improvement
  Components: AndroMDA Query  
    Reporter: Lee Greiner
 Assigned to: Chad Brandon 
    Priority: Minor


HQL supports the SQL distinct keyword. There is currently no OCL query support 
for injecting the distinct keyword in the generated HQL.

One example:

A User entity that has a 0..* to 1..* relationship to a Role entity.

The OCL query

context User::findUsersByRole( roleNames:Collection(String)):Collection(User) 
body : allInstances() -> select ( user | roleNames  -> 
includes(user.roles.name) )
-> sortedBy(user.name.lastName)
-> sortedBy(user.name.firstName)

generates the following HQL:

from User as user where user.roles.name in (:roleNames) order by 
user.name.lastName, user.name.firstName

which returns duplicate Users if a users have multiple Roles.

Prefacing the HQL with "select distict user" returns the desired results yet 
there is no OCL support that generates this HQL.




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642

Reply via email to