You cannot check if the L2 cache is enabled directly but you can check its content, by using emf.getCache().contains(entityClass, primaryKey), so you can persist or retrieve an entity object and then check if it is cached.
The L2 cache doesn't always improve performance. It depends on the application. Sometimes enabling the L2 cache may slow the application because of the overhead in keeping it up to date and the memory that it consumes. Therefore, it is disabled in the default configuration by setting its size to 0.
The main problem with the default implementation is that the server doesn't know what is cached on the client side, and therefore when a query is executed by the server it prepares all the results, regardless the cache. So the cache is mainly useful for retrieval by find and by navigation (and not in queries).
You may try the following undocumented ObjectDB query hint and check if it helps:
query.setHint("objectdb.result-fetch", "lazy");
This is an instruction to the ObjectDB server to return references rather than entity objects as results, which can help in using the L2 cache on the client side. It might be mainly useful in queries that can be resolved by indexes without accessing the primary data.
Currently this hint must be set at the query level (as demonstrated above) - but it should be supported in all other query hint scopes in future versions.