[ 
http://galaxy.andromda.org:8080/jira/browse/OCL-5?page=comments#action_11193 ]
     
Chad Brandon commented on OCL-5:
--------------------------------

No I left it default to unnamed because of the fact that lots of users have the 
HQL queries embedded in their models as tagged values (bad practice)...so 
anyway I didn't want to break everyone's queries by all of a sudden changing 
the default.

> improved handling of finder parameters
> --------------------------------------
>
>          Key: OCL-5
>          URL: http://galaxy.andromda.org:8080/jira/browse/OCL-5
>      Project: OCL Translation
>         Type: Improvement
>     Reporter: Wouter Zoons
>     Assignee: Chad Brandon
>      Fix For: 3.0RC1

>
> I have this OCL fragment as a finder query on an operation called
> "findValidByUser" of entity "MedicalCertificate":
> context MedicalCertificate::findValidByUser(userId:Long,date:Date) :
> Collection(MedicalCertificate) body findValidByUser :
> allInstances->select(certificate | certificate.user.id = userId and
> certificate.validityStart <= date and certificate.validityEnd >= date)
> note how there are two parameters to that operation, while I use them
> three times in total (userId is used once, and date is used twice)
> this translates into something like this (query + spring generated code):
> QUERY:
> ------
> from be.sylis.vw.akvdt.medicalcertificate.MedicalCertificate as
> certificate where certificate.user.id = ? certificate.validityStart > ? or
> certificate.validityEnd < ?", userId, date)
> JAVA:
> -----
>     public List findValidByUser(...)
>     {
> ...
>                 queryObject.setParameter(0, userId);
>                 queryObject.setParameter(1, date);
> ...
> IMHO it would be a better idea to do this instead:
> (in the query the question marks are replaced by the parameter names
> prefixed with a colon)
> (in the java code the parameter substitution is updated to reflect the
> change in the query)
> QUERY:
> ------
> from be.sylis.vw.akvdt.medicalcertificate.MedicalCertificate as
> certificate where certificate.user.id = :userId certificate.validityStart
> > :date or certificate.validityEnd < :date", userId, date)
> JAVA:
> -----
>     public List findValidByUser(...)
>     {
> ...
>                 queryObject.setLong("userId", userId);
>                 queryObject.setDate("date", date);
> ...
> doing so is IMO more inline with the OCL code, and it allows us to
> logically reuse parameters in the query itself

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://galaxy.andromda.org:8080/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Andromda-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/andromda-devel

Reply via email to