improved handling of finder parameters
--------------------------------------
Key: OCL-5
URL: http://team.andromda.org:8080/jira/browse/OCL-5
Project: OCL Translation
Type: Improvement
Reporter: Wouter Zoons
Assigned to: Chad Brandon
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://team.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://productguide.itmanagersjournal.com/
_______________________________________________
Andromda-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/andromda-devel