Consider an example where the entity Employer has a method CountEmployers (stereotype ns) which returns the number of records in the Employer table.
The following struct is required to return the result, since stereotyped entity operations cannot return primitive types:
public final class LongWrapper implements Serializable, DeepCloneable { /** * LONG_TYPE -> long */ public long longValue = 0; }
The Java interface for this operation would look like the following extract:
public interface Employer { public LongWrapper countEmployers() throws AppException, InformationalException; }
Finally, the SQL to implement this query is:
SELECT count(*) INTO :longValue FROM Employer;
Note that we do not need to specify the name of the LongWrapper class, we simply reference the name of the longValue attribute within that class because the INTO clause is automatically assumed to reference the return value.
Thus if an attribute with the same name is used in the input parameter struct and return value struct then it is assumed that INTO clause references the attribute of return value struct.