Input Parameters

Home > Query Language > Basic Concepts > Input Parameters

Query languages typically support input parameters. For example, the Java Persistence Query Language supports positional and named parameters.

// positional parameter
String q = "
    SELECT p
    FROM Person p
    WHERE p.spouse = ?1
";
em.createQuery(q).setParameter(1, spouse);

// named parameter
String q = "
    SELECT p
    FROM Person p
    WHERE p.spouse = :spouse
";
em.createQuery(q).setParameter("spouse", spouse);

As the previous example illustrates, input parameters are essential for string-based query languages: they are needed for passing object paramaters like "spouse" - a person.

OOMEGA does not support input parameters. They would be useless because OOMEGA's query language is model-based and integrated in Java, i.e. you are able to pass objects to queries directly. Please have a look at the following code snippet: the person "spouse" is part of the query.

Query(
   from(Person.CID),
   where(
      eq( P(Person.P.spouse), spouse )
   )
);

Next chapter: Identification Variables

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.