Search code examples
cassandradatastax-java-driver

How to print UDT as shown in CQL Shell with Java driver


Somebody knows how to print my UDT so it shows in console as it shows in CQL Shell? This:

rs = session.execute(statement);
row = rs.one();
resultUDT = row.getUdtValue(0);
System.out.println(resultUDT);

Gives me the Objects name

com.datastax.oss.driver.internal.core.data.DefaultUdtValue@6f378182

I also tried with same result:

System.out.println(resultUDT.toString());

I am looking for something like:

{param1: 6, param2: 10,param3: [2829547778, 1927366853, 2775082582, 4232025523, 2258965237, 2897381885, 3224321316], ...}

Probably converting somehow to JSON?

I'd appreciate any hint. Thanks


Solution

  • Sorry for the inconvenience. Found it quite fast: getFormattedContents()