Reputation: 1223
I've got an object that represents an Artefact:
public class Artifact {
private final URI location;
public Artifact(URI location) {
this.location = location;
}
}
When I use MongoTemplate
to save this, the URI gets turned into an object:
{ "location" : { "scheme" : "http", "authority" : "localhost:8080", "host" : "localhost", "port" : 8080, "path" : "/testFrontendURL", "schemeSpecificPart" : "//localhost:8080/testFrontendURL", "hash" : 331612143, "string" : "http://localhost:8080/testFrontendURL" }
But, this could just be represented by the URI string:
{"location": "http://localhost:8080/testFrontendURL"}
How can I configure Spring Data to do this?
Upvotes: 0
Views: 58
Reputation: 5466
You can write your own convertors
References: http://docs.spring.io/spring-data/mongodb/docs/1.2.0.RELEASE/reference/html/mapping-chapter.html
Spring data mongodb query converts String to ObjectId automatically
Upvotes: 1