Session.java Addition

Last modified by David Avendasora on 2009/03/26 09:11

These additions are based on a more advanced Stateless RMI concept by Florijan Stamenkovic.

public EOFetchSpecification clientSideRequestGetFetchSpecification(String fetchSpecification,
                                                                  String entity) {
return getFetchSpecification(fetchSpecification,
                            entity);
}

/**
 * Loads and returns an <tt>EOFetchSpecification</tt> objects for the given specification and entity name.
 *
 * @param fetchSpecification
 *            Name of the specification
 * @param entity
 *            Name of the entity
 * @return A fetch specification, or <tt>null</tt> if it is not found, or an error occurs
 */

public EOFetchSpecification getFetchSpecification(String fetchSpecification,
                                                 String entity) {
try {
// NSLog.out.appendln("About to call FetchSpecification " +
// fetchSpecification + " on Entity " + entity);
return EOFetchSpecification.fetchSpecificationNamed(fetchSpecification,
                                                   entity);
} catch (Exception ex) {
NSLog.out.appendln(ex);
return null;
}
}
 

Warning
Caution

Due to security concerns you cannot call FetchSpecifications from the client-side that use a Raw SQL Expression without implementing the delegate method distributionContextShouldFetchObjectsWithFetchSpecification which this code does NOT do.

If you try to, you will get the following exception in the server log:

Server exception: The fetchSpecification YourFetchSpecificationWithRawSQLExpression was not allowed to execute on the server. If your application needs to execute this method, the security needs to be relaxed by implementing the delegate method distributionContextShouldFetchObjectsWithFetchSpecification

and this code will return null to the client instead of the expected FetchSpecification.