I am trying to add a Map field in my oracle nosqltable (in the example given here https://docs.oracle.com/en/database/other-databases/nosql-database/21.1/java-driver-table/accessing-nosql-using-sdf.html) but when saving its not getting saved properly by Spring data.
Customer.java
@NosqlTable(storageGB = 1, writeUnits = 10, readUnits = 10)
public class Customer {
@NosqlId(generated = true)
long customerId;
String firstName;
String lastName;
Map hashMap;
Date createdAt;
@Override
public String toString() {
return "Customer{" +
"customerId=" + customerId +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", createdAt='" + createdAt + '\'' +
", hashMap='" + hashMap + '\'' +
'}';
}
}
CustomerRepostory.java
import com.oracle.nosql.spring.data.repository.NosqlRepository;
public interface CustomerRepository
extends NosqlRepository<Customer, Long>
{
Iterable<Customer> findByLastName(String lastname);
}
When I call the following code to create a customer row :
Customer s1 = new Customer();
s1.firstName = "John";
s1.lastName = "Doe";
HashMap s1Map = new HashMap() ;
s1Map.put("name", "myMap") ;
s1Map.put("use", true);
s1.hashMap = s1Map;
repo.save(s1);
It gets saved as
{
"createdAt": null,
"firstName": "John",
"hashMap": {
"entrySet": null,
"keySet": null,
"loadFactor": 0.75,
"modCount": 2,
"size": 2,
"table": [
null,
null,
null,
null,
null,
null,
{
"hash": 116102,
"key": "use",
"next": null,
"value": true
},
null,
{
"hash": 3373752,
"key": "name",
"next": null,
"value": "myMap"
},
null,
null,
null,
null,
null,
null,
null
],
"threshold": 12,
"values": null
},
"lastName": "Doe"
}
Can someone please help me with correct data type to use for nosql map ?