We've been happily using Andromda, but I have encountered an issue I'm sure has been encountered before but I can't find anything about it.
I want to have finders that have the signature "Entity find(Entity)". The implementation would use the business key of the Entity (typically a transient instance) to find a matching persistent instance. In our application the query Entity is often coming from another datasource, and we want to match it up to an existing instance in our database. The obvious usual way to do this is to dereference the appropriate attributes of the Entity (so you would have find(String entity.AttributeA(), String entity.AttributeB()) or something like that). That we can do already. But to hide the details of the business key from the user of the API, I want to have the method do the dereferencing. Ideally, Andromda would generate the code for us. Thus far we've been writing our queries in HQL, but unfortunately HQL won't let you dereference a parameter - so we can't use the HQL tagged value. It's easy enough to do this with a criterion query, but we don't want to have to pass in a Criteria object to the method. My current workaround is to implement this by hand, but it seems like I'm missing something. I haven't used OCL, but I'm willing to if it can do this for me in one query. To make it explicit, the hql we would want to generate for a non-trivial case (Foo has association to the entity Bar, and Bar is part of the business key) might look like: from foo as f inner join f.bar as b where f.attribute=:attributeA and b=:attributeB but the only input we have is a Foo. I wish I could write from foo as f inner join f.bar as b where f.attribute=:foo.attributeA and b=:foo.attributeB With a criteria query, this is easy: Criteria queryObject = super.getSession( false ).createCriteria( Foo.class ); queryObject.add( Restrictions.eq( "attributeA", foo.getAttributeA() ) ).add( Restrictions.eq( "attributeB", foo.getAttributeB() ) ); My question is, can this be done in a single line of OCL, so we can put the query in our UML? Something like: context edu::columbia::blah::Foo::find( queryFoo:Foo):Collection (Foo) body : allInstances() -> select ( foo| foo.attributeA = queryFoo.attributeA and foo.attributeB = queryFoo.attributeB ) The key question is if OCL (and Andromda) supports the queryFoo.attributeA syntax. If not, if you have any other suggestions... I was also wondering if anybody knew how to set up OCL queries in Poseidon, or if not, if you could point me to instructions for MagicDraw so I can translate. In Poseidon's interface a constraint has a "name", "language", "sterotypes" and "body", and I don't know how to fill all of those slots in so they get recognized by Andromda. Thanks _________________________________________________________ Reply to the post : http://galaxy.andromda.org/forum/viewtopic.php?p=2135#2135 Posting to http://forum.andromda.org/ is preferred over posting to the mailing list! ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ Andromda-user mailing list Andromda-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/andromda-user