Can anybody show an example of how to use heap.heapForEachClass in a select statement?
It would be great if you could provide some links with different examples of queries (other than those in the oqlhelp page of course 🙂 )
Can anybody show an example of how to use heap.heapForEachClass in a select statement?
Share
I don’t believe heap.forEachClass() is meant to be used in a select statement, at least not directly. Consider the fact that it doesn’t return anything:
The OQL used in jhat and VisualVM does support plain ol’ JavaScript, just like the “query” I use above. I believe that the heap.forEachClass() finds more use in either JavaScript-style queries or in JavaScript functions within select-type queries.
That said, I don’t know why this function exists since the heap.classes() enumeration is much easier to use, both with with select-style queries and plain JavaScript ones.
You could even even recreate the same functionality as heap.forEachClass() with the following JavaScript function:
Any sample queries that I could provide you would likely be easier written with heap.classes(). For example, you could use heap.forEachClass() to get list of all classes:
but this is more complicated than how you’d do it with heap.classes():
or just