cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Gentry" <blackn...@gmail.com>
Subject Re: Pb implement JOIN function
Date Fri, 08 Feb 2008 14:35:38 GMT
Using Cayenne Modeler, you can define a relationship from SMASTER to
JSTATMAP using two joins.  Create the join, say in SMASTER, and click
the "I" inspector button to establish this.  Will this do what you
want?  If so, then you should be able to perform your query something
like this:

Expression expression = Expression.fromString("jstatmap.filtercat =
'CANCELLED'");
SelectQuery  = new SelectQuery(Smaster.class, expression);
List values = dataContext.performQuery(query);


If this isn't what you are looking for, look into the SQLTemplate feature.

/dev/mrg


On Feb 7, 2008 4:44 PM, Francois Eyl <feyl@smaeur.com> wrote:
> Hello guys,
>
> I have a question about how to join multiple object entities.
>
> Concrete sample :
>
> I have 2 tables with no foreign key between them (poor database).
>
> The first one is named SMASTER with 5 columns [SKDDATE (PK), SKDID (PK),
> JOBNAME (PK), JOBSTATUS, STSTATUS].
> The second one is named JSTATMAP with 3 columns, [JOBSTATUS (PK),
> STSTATUS (PK), FILTERCAT].
>
> I also have my cayenne user object entities named Smaster and Jstatmap
> with all their properties and their getters and setters.
>
> I'm trying to create a cayenne query to retrieve Smaster objects related
> to a specifique FILTERCAT value. In pure SQL the request would be
> something like that:
>
> SELECT SKDDATE, SKDID, JOBNAME, JOBSTATUS, STSTATUS
> FROM SMASTER
>     INNER JOIN JSTATMAP ON
>         JSTATMAP.JOBSTATUS=SMASTER.JOBSTATUS AND
>         JSTATMAP.STSTATUS=SMASTER.STSTATUS
> WHERE JSTATMAP.FILTERCAT='CANCELLED'
>
> But I can't find the way with cayenne to do the same thing with Query
> and Expressions. Is there a way to do a "JOIN" between two or multiple
> cayenne object entity?
>
> Thanks.
>
> Francois
>

Mime
View raw message