string search using OQL - visualvm

I am using VisualVM to analyze a core dump. I suspect some XML objects to be causing the leak but there are way too many String objects to go through one by one.
Can I use OQL to search String that begin with 'GH' ?
thanks for any help.

under JDK 1.8.20 a more simple variant works:
select s from java.lang.String s where s.toString().startsWith("GH")

Try this:
select {instance: s, content: s.toString()} from java.lang.String s where s.count>2 && s.toString().substring(0,2)=="GH"

heap.objects('java.lang.String', false, "it.toString().startsWith('GH')")

select c.attr_name.toString() from a.b.c.MyClass c where c.attr_name.toString().startsWith("GH")

Related

Array stored as String - How to extract pieces of it?

I got a problem with a specific database where some tags from a user profile are stored as a String data type, and so far I have not figured out how to fetch data from this one.
Example String:
{"watch_intro": "Gifts from my family.", "favorite_brands_styles": ["Fossil","Tudor","Omega"]}
I am looking to query into this field and get something like below:
'Fossil, Tudor, Omega'
Any help would be appreciated, thanks.
Nevermind, found the answer:
array_to_string(PARSE_JSON(EXTRA_INFO):"favorite_brands_styles",', ') AS fav_brands

laravel 5.2 how to use the count query with where query

I have tried every where all examples I came across but still have the same problem error 'htmlentities() expects parameter 1 to be string, array given'
I need to select count from the database and would like to use the raw select as i will have more flexibility on it but any point towards the right direction will be appreciated here is what i have been doing'
$totalOpen = DB::table('dam')
->select(array('dam.*', DB::raw('COUNT(dam.mivisjobid) as followers')))
->join('miviswf','miviswf.mivisid','=','dam.mivisjobid')
->whereRaw( 'miviswf.mivisid=dam.mivisjobid')
->whereIn('miviswf.Status', $inputIds) // pass an array
->orderBy('miviswf.datetimesubmitted', 'ASC');'
and i get this error 'htmlentities() expects parameter 1 to be string, object given (View: '
Try with this, don't use array inside the select method
->select('dam.*', DB::raw('COUNT(dam.mivisjobid) as followers'))
for reference:
https://laravel.com/docs/5.2/queries#selects
This worked fine
DB::table(' dam')
->count();

How to locate the node in JCR using uuid from query

This is the error I get.
16.03.2016 12:02:16.413 WARN [xxx.xxx.xx.xxx [1458147736268] GET /en/employees-leaders/employee-s-toolkit2/epd-update/epd-update-archives/caterpillar-news/upcoming-brand-webinarfocusonmarketing.html HTTP/1.1] com.day.cq.wcm.core.impl.LanguageManagerImpl Error while
retrieving language property. javax.jcr.AccessDeniedException: cannot
read item xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (alpha-numeric)
I am trying to locate the node in JCR using the xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, which I believe is uuid, using a query in AEM.
Is the xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx actually a uuid?
How do I locate the source i.e node, causing the issue?
I tried running a sql with the above id in the jcr, but it returned no result.
//*[jcr:contains(., '91186155-45ad-474-9ad9-d5156a398629')] order by #jcr:score descending
Any other insights would be much appreciated.
You don't need a query if you know the Node's UUID, just use the Session.getNodeByIdentifier(String id) method.
Your query is not SQL as you stated, it's XPATH. Is that a typo or did you run the query incorrectly?
It certainly looks like a UUID. You can query for the jcr:uuid property or you can continue doing a full text search.
XPATH:
/jcr:root//*[jcr:contains(., '91186155-45ad-474-9ad9-d5156a398629')]
/jcr:root//*[#jcr:uuid='91186155-45ad-474-9ad9-d5156a398629']
JCR-SQL2:
SELECT * FROM [nt:base] AS s WHERE contains(s.*, '91186155-45ad-474-9ad9-d5156a398629')
SELECT * FROM [nt:base] WHERE [jcr:uuid] = '91186155-45ad-474-9ad9-d5156a398629'
What read permissions does your account have? You're going to find a lot of results for a jcr:uuid query will be under /jcr:system/jcr:versionStorage.
Use QueryBuilderDebugger, (localhost:4502/libs/cq/search/content/querydebug.html) and run similar query as below to get the node for a given uuid:
property=jcr:uuid
property.value=e69b256e-a466-3730-866b-de22c82ab8ck
path=/home
type=rep:Group
p.limit=10

OQL all instances from a package

Is it possible in OQL to retrieve all the objects that belongs to a package? Or can I query with wildcards?
As #haridsv suggested I tried:
SELECT * from "com.example.*"
and
SELECT a from "com\.example\..*"
but in VisualVM it complaints that no such package exists.
Even
SELECT a from "java.io.File" a
Fails.
Thanks!
ssedano.
You can use regular expression like this:
SELECT * from "<packagename>.*"
If the package name is "java.io" you would use:
SELECT * from "java\.io\..*"
Note the quotes around the regex and how the dots in the path are protected.
I found the answer in VisualVM OQL help.
select filter(heap.classes(), "/com.example./(it.name)")
From VisualVM limited documentation:
select all classes that have name pattern java.net.*
select filter(heap.classes(), "/java.net./.test(it.name)")
https://visualvm.github.io/documentation.html
The trick is in the "test(it.name)"

How to create a dynamic query using EOD SQL?

This should be fairly simple, though I can't seem to find a single example.
I want to create a query looking like this:
SELECT column_name FROM table_name WHERE column_name IN (value1,value2,...)
As an option I could append OR-clauses to the end of the query.
The code I have written so far keeps blowing up with a Nullpointer:
#Select(sql = "select storename from broadcastrecipient where storecity in (?{1})")
public List<String> getStoresForCities(List<String> theCities) throws SQLException;
Thanks in advance.
//Abean
NOTE: I forgot to add some info about my env: PostGres 8.3, Java 1.6 and EOD SQL 0.9.
Thank you Jason.
For those who like to know, the query looks something like this:
#Select(sql = "select distinct(storename) from broadcastrecipient where storecity = any (?{1})", disconnected=true)
public List<String> getStoresForCities(String[] theCities) throws SQLException;
And I also needed to implement a TypeMapper class to map SQL-array to Java array.
I would suggest looking at EoD SQL 2.0: https://eodsql.dev.java.net/
Then take a look at the QueryTool.select() method which is designed exactly for this situation.
EoD SQL 0.9 has no functionality to cope with this sort of query built in.
A really ugly hack is to create a temp table, and populate it with your array data. Then run the query as:
#Select("SELECT storename FROM broadcastrecipient WHERE storecity IN (SELECT * FROM tmp_cities)")
public List<String> getStoresForCurrentCities();