- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有2个java应用程序。 Soap 服务器 (jax-ws) 和 Soap 客户端。 Soap服务器使用spring mongo和mongoDb作为数据库。所以,在我的服务器上,我有返回所有公司的方法
@WebMethod(operationName = "getCompanies")
public CompanyList getCompanies(){
CompanyList companyList = new CompanyList();
companyList.companyDocArrayList = Lists.newArrayList(orgStructService.getCompanyDocService().findAll());
return companyList;
}
公司列表类
public class CompanyList {
public ArrayList<CompanyDoc> companyDocArrayList;
}
和公司文档
public class CompanyDoc{
@Id
private ObjectId id;
private String companyName;
//getter setter
}
所以,当我调用这个方法时
ClientService clientService = new ClientService Service().getClientServicePort();
modelMap.addAttribute("companyList", clientService.getCompanies().getCompanyDocArrayList());
在列表中的 clientService.getCompanies() 中,我得到奇怪的 objectId,例如 com.web.client.services.ws.ObjectId@45ee7ab1 (45ee7ab1 - 此值每次刷新页面都会更改)但在数据库中它是 5369fefa1d6e6712866daaea
我做错了什么?
最佳答案
似乎JAX-WS
不知道如何将ObjectId
对象转换为String
。我不知道您如何使用文档,但我认为您可以在 CompanyDoc
对象中使用 String
而不是 ObjectId
。当您插入数据时,Spring data
会将您的 String
转换为 ObjectId
,反之亦然。
public class CompanyDoc{
@Id
private String id;
private String companyName;
//getter setter
}
更多信息来自documentation
The following outlines what type conversion, if any, will be done on the property mapped to the _id document field when using the MappingMongoConverter, the default for MongoTemplate.
- An id property or field declared as a String in the Java class will be converted to and stored as an ObjectId if possible using a Spring
Converter. Valid conversion rules are delegated to
the Mongo Java driver. If it cannot be converted to an ObjectId, then the value will be stored as a string in the database.- An id property or field declared as BigInteger in the Java class will be converted to and stored as an ObjectId using a Spring
Converter.
关于java - 从soap web服务返回ObjectId,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23525747/
假设我在文件开头有这个定义: const ObjectId = mongoose.Types.ObjectId; 您更喜欢哪一个,为什么? // 1 new ObjectId; // 2 new O
我通过以下两种不同的方法生成了一个 ObjectId: user@ubuntu:~$ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
我编写了一个 Python 代码,用于从名为 Tweets 的 Mongo 集合中获取推文。我不想只获取对象文本并添加一个名为 Sentiment 的附加对象。 当我循环推文并将 json 对象解析为
我是 Node.js 和 mongodb 的新手。 在我的 Node.js 应用程序中,我使用的是 mongodb,对于 mongodb 操作,我使用的是 mongoose。 在 package.js
使用 parse.com 和 JavaScript SDK。 这就是我想要实现的目标。 页面上将用户( friend )列表返回给用户,然后他们可以单击其中一个用户,页面将更新以列出所有该用户的项目(
我有一个像这样的 objectId:["56153e4c2040efa61b4e267f","56033932efefe0d8657bbd9e"]为了在我的模型中保存该信息,我使用: items: [
我有一个标签模式: const TagSchema = new Schema({ label: {type: String, unique: true, minlength: 2}, upda
在online API他们指的是 Mongo::ObjectID。 我有 require 'mongo' 但 ruby 仍然找不到它。例如,我需要通过它的 Id 找到一个对象,我正在做: mong
作为管道的最后阶段,我有一个像这样的 $project : { ... anId : new ObjectId() } 但是 mongo 为每个文档生成相同的 Id。我希望它为每个投影文档生成
我需要在这样的数组中找到 mongoose objectID 的索引: [ { _id: 58676b0a27b3782b92066ab6, score: 0 }, { _id: 58676aca
我们可以从客户端生成 ObjectId 并在插入时使用它。我确实希望它在插入过程之外进行处理。我需要将其配置为我的默认 _id 生成过程,以便当我调用 insert 时,insert 方法应该创建自定
这是代码。跟随者和追随者无法工作。换句话说,我无法将像 {"user1", objectId1} 这样的对象推送到这两个数组。是否允许有一个字段同时包含对象 ID 和字符串名称?感谢您的帮助。 The
为什么 Meteor.js 使用它自己的 IDsp 算法> 为什么不使用 MongoDB ObjectId()? 最佳答案 如果你选择使用 Meteor,它对对象 ID 使用相同的方法: Meteor
Mongoose 菜鸟问题:我有两个 Mongoose ObjectId 对象列表,我将它们合并为一个。有些 ObjectId 是重复的,我不想将它们保存到我的数据库中。是否有 Mongoose 工具
以下代码从供应商集合中的员工数组中提取员工 await new VendorManager() .update( { emplo
我有一个简单的模型对象: class UserRating include MongoMapper::EmbeddedDocument key :idea_id, ObjectId key
谁能告诉我使用 #[objectId] 或 [id=objectId] 引用元素有什么区别? 最佳答案 第一个非常快,因为 jQuery 内部使用 getElementById当它识别出模式时(使用正
我的架构是: var schema = new Schema({ players: { type: [Schema.Types.ObjectId]}); 我正在使用 promi
这似乎是这样定义我的架构: var PossessionSchema = new mongoose.Schema({ thing: {type: mongoose.Schema.Types.Obj
我想要解决的是:使用建议的方法(mapReduce)保留 $in 中的 Id 数组的顺序: Does MongoDB's $in clause guarantee order 我已经完成了我的作业,发
我是一名优秀的程序员,十分优秀!