我有一个简单的Spring Rest服务设置来处理我在DB中的一些JSON对象。我有两个申请;一个希望保存该数据,另一个希望将数据本地请求/存储到其数据库。使用的对象是两个应用程序都可以访问的共享Jar,因此他们知道结构,期望等。
当我运行数据请求时,我可以看到它进入,但是一些数据已经在JSON中被删除了。我在源系统的最后一个返回点设置了断点,当数据存在(从数据库中拉出)并准备好返回时,它就完好无损。一旦它通过邮递员或我的第二个应用程序以任何形式通过电汇,一些字段已被消隐。
编辑:为了便于阅读,发布了一些简化了特定名称的代码
//------------------The Data "Source"------------------------------
//The source service that serves the content
@ResponseBody
@RequestMapping(value = { "/json/listObjectA" }, method = RequestMethod.GET)
public List<ObjectA> listAllObjectA() {
List<ObjectA> allObjectA = ObjectA
.getAll(thisApplicationContext);
return allObjectA; //a breakpoint here shows the data as expected
//the data in the DB is correct in source, confirmed.
}
//------------------The Requesting "Target"-----------------------------
//trying to get that data, setting up a baseURL for the service works
//when using this block of code with debuggers on, it reaches the source above.
RestTemplate rest = new RestTemplate();
ResponseEntity<ObjectA[]> sfResponse = rest.getForEntity(
coreBaseLocation+"json/listObjectA",
ObjectA[].class);
ObjectA[] sfList = sfResponse.getBody();
// right here debugging, the list has the correct number, but some of the data is missing
for (ObjectA sf: sfList) {
sf.setId(null); //clear the local id, a uuid is persisting
sf.save(thisApplicationContext);
}
//------------------The data class------------------------------
@Entity
public class ObjectA{
...
protected String ObjectBUuid;
protected String ObjectCUuid;
...
// basic POJO getters/setters/constructor etc. nothing fancy
另外作为参考,ObjectA
是一个简单的&#34;加入&#34; ObjectB
和ObjectC
之间的对象。一个简单的连接表并不起作用,因为我存储了很多关于该关联的元数据,这些数据与此不相关但是出于商业原因需要。
//Here is a copy of the "response" from Postman hitting that json url.
//again, in debug before this is sent back the data looks correct with the Uuids populated (like in the DB)
[
{
"id": 1, //local id of the ObjectA
"uuid": "1464d8dc-0281-4850-a51d-a375f7a2fd04", //ObjectA's uuid
... metadata stuff ...
// end of obj., no reference to the ObjectB/C uuids at all in the returned obj.
}, // more data here matching the number I expect from the DB and the source debug breakpoint, just with the reference uuid missing.