Re: this works, but is there a better way?

Michael Gentry <[email protected]> Tue, 7 Apr 2026 19:28:48 -0400
Newsgroups gmane.comp.java.cayenne.user
Message-ID <CAOy5kzPmZYsjow+4+KyGc-3q4NjLNmoeX6WhJKvqjvR0uzkOPQ@mail.gmail.com>
--000000000000553823064ee72701
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I think a custom enum is the better approach. You don't want someone
refactoring the class name and then your query no longer matches the DB
column entries.

On Tue, Apr 7, 2026 at 8:42=E2=80=AFAM Andrus Adamchik <[email protected]=
> wrote:

> Oh, I got it. There are no special Cayenne shortcuts for this. So you'll
> have to use your own conventions
> (AiSystemPromptSummarization.class.getSimpleName(), or define possible
> constants in a custom enum).
>
> Andrus
>
>
>
> > On Apr 7, 2026, at 8:27=E2=80=AFAM, Robert A. Decker <decker@robdecker.=
com>
> wrote:
> >
> > In my query I'm using a hardcoded string but if I change the qualifier
> in the cayenne modeler to, for example, use a different column or change
> the string in the qualifier it won't match the query.
> >
> > So, I should use the actual qualifier from the modeler but I don't see
> the qualifier in the class variables. Does it only live in the modeler?
> >
> > Basically I just don't want to use a string that I have in my code.  I
> could use something like just the class name of the class but that may no=
t
> match the qualifier.
> >
> > Rob
> >
> > Sent from my iPhone
> >
> >> On Apr 7, 2026, at 14:04, Andrus Adamchik <[email protected]> wrote:
> >>
> >> =EF=BB=BFHi Rob,
> >>
> >> In your example, both the entity qualifier and the condition in "where=
"
> seem the same. So you wouldn't need the latter if you have the former. Am=
 I
> misreading the description?
> >>
> >> Andrus
> >>
> >>> On Apr 7, 2026, at 7:48=E2=80=AFAM, Robert A. Decker <decker@robdecke=
r.com>
> wrote:
> >>>
> >>> I'm using single-table inheritance with the 'type' column determining
> the subclass with a Qualifier in the model:
> >>> AiSystemPrompt (abstract)
> >>> AiSystemPromptSummarization (Qualifier
> type=3D'AiSystemPromptSummarization')
> >>>
> >>> This query works:
> >>>
> >>> List<AiJob> jobs =3D ObjectSelect.query(AiJob.class)
> >>>
> .where(AiJob.AI_SYSTEM_PROMPT.dot(AiSystemPrompt.TYPE).eq("AiSystemPrompt=
Summarization"))
> >>> .select(context);
> >>>
> >>> But I don't like that I'm hardcoding the subclass
> ("AiSystemPromptSummarization") and searching against the TYPE property.
> >>>
> >>> Is there a way to do this using the attributes I have in the cayenne
> model? (abstract superclass with concrete subclass using the qualifier se=
t
> in the entity model)
> >>>
> >>> I looked at BaseProperty and a couple of others in
> org.apache.cayenne.exp.property but don't see it....
> >>>
> >>> Rob
> >>
>
>

--000000000000553823064ee72701--