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
how hard is this to do ? Chad, if you point me in the good direction I can
do it if you want.
-- Wouter
-------------------------------------------------------
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