Wouter Zoons dijo lo siguiente el 23/03/2005 13:01:
I've looked into the templates, and I think that this DAO base class is generated only for spring cartidge (correct me if i am wrong) and I am not using it. I'm using hibernate cartridge.Hi,if you model the finder method to have the 'Personas' type then you're
I'm trying to do a method with an OCL that returns an object.
The OCL assigned to the method is the following:
context Personas::findByFechaEdadYDNI(fecha:Date,edad:Integer,dni:String):Personas body : allInstances()-> select ( persona | persona.fnacimiento <= fecha and (persona.ffallecimiento > fecha or persona.ffallecimiento = null) and persona.edad = edad) and persona.dni = dni
I know that this select is going to return just one instance... so I don't want a collection of objects with one object, I just want the object.
safe, if the database would ever return more than one element it will
throw an exception (check the finder DAO base class)
I have the finder method generated into PersonasFactory.java.
I've corrected the query, but I still getting compilation error.The method (in the diagram) that holds this constraint returns theokay, good
correct type and receives the corrects parameters (also their types).
that could be due to the fact that your query is a bit malformed, tryI'm getting two problems. First, the signature of the result method returns the correct type Personas, but the implementation still doing return query.list(); This causes a compilation error of the generated source because of the types diference between the method signature and the returned type of list method.
putting the trailing 'and persona.dni = dni' before the closing ')'
the method is:
public static test.mispruebas.Personas findByFechaEdadYDNI(net.sf.hibernate.Session session, java.util.Date fecha, java.lang.Integer edad, java.util.String dni)
{
[...]
return query.list();
}
this can not compile... :'-(
Ok, I'd tried it, but... if I put: persona.ffallecimiento->isEmpty() the translation is: size(persona.ffallecimiento) = 0... and that doesn't run on PostgreSQLSecond, the *= null* clause is translated as is. I'm using PostgreSQL and this sentence doesn't work. I need *= null* to be translated into *is null*
= null does not exist in OCL, you should try 'persona.ffallecimiento->isEmpty()' (->isEmpty() works on all instances, it's predefined OCL construct but mainly used on collections)
likewise, you also have the '->notEmpty()' construct, which does exactly
the opposite
persona.ffallecimiento is a nullable attribute, and I want to select the ones having it set to null (ffallecimiento means death date... and not all the persons I have in the database are dead :-S)
I just want to check if the person is (or was) alive in the date I receive. Can I use isEmpty() also for attribute values, or is it only for collections?
Bruno
------------------------------------------------------- This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to win $25,000 and application distribution. Enter today at http://ads.osdn.com/?ad_id=6882&alloc_id=15148&op=click _______________________________________________ Andromda-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/andromda-user
