MongoDB将所有现有索引迁移到新数据库(MongoDB Migrate all existing indexes to new database)
作为开发改进的一部分,我有一个MongoDB开发集群,我在那里创建索引。 在测试/生产MongoDB集群上,我也想维护相同的索引。
那么如何获取现有集合的所有索引并在新数据库上创建相同的集合索引?
I have a MongoDB development cluster where i create indexes over time as a part of development improvements. On Testing/Production MongoDB cluster also, i want to maintain the same indexes.
So how do i get all indexes of existing collections and create the same collection indexes on new database?
原文:https://stackoverflow.com/questions/46993021
最满意答案
我不确定你的意思是“外键必须在OptIn中”。 您已通过
@PrimaryKeyJoinColumn
映射您的@OneToOne
关联,这意味着您的实体将通过其ID值进行关联。 这也意味着:
- 您无法在
@PrimaryKeyJoinColumn
注释中指定列名称; 它们将取自两个实体的相应@Id
列。- 标记为
LAZY
是毫无意义的并且将被忽略; 可选的@OneToOne关联总是被热切地提取。OptIn
在这个关联中可选的唯一方法是如果数据库中没有给定ID的条目。您使用的是何种Hibernate / Annotations版本? 如果它们很老,那可能是Hibernate代码中的一个错误。 但是我相信如果你修正上面的(1)和(2),它应该可以工作。
I'm not sure what you mean by "foreign key must be in OptIn". You've mapped your
@OneToOne
association via@PrimaryKeyJoinColumn
which means your entities will be linked via their ID values. It also means that:
- You can't specify column names within
@PrimaryKeyJoinColumn
annotation; they will be taken from appropriate@Id
columns on both entities instead.- Marking fetch as
LAZY
is pointless and going to be ignored; optional @OneToOne associations are always eagerly fetched.- The only way
OptIn
would be optional on this association is if there was no entry with given ID in the database.What Hibernate / Annotations versions are you using? If they're rather old it could be a bug in Hibernate code. But I believe it should work if you fix (1) and (2) above.
相关问答
更多-
处理DB调用的标准方法是:1。打开连接2.打开会话和/或事务3.执行操作4.关闭事务和/或处理5.关闭连接 这基本上就是那个注释为你做的事情;)我强烈建议学习更多关于用这些东西去除的东西。 Standard way of handling DB calls is to : 1. open connection 2. open session and/or transaction 3. do stuff 4. close transaction and/or seasion 5. close connecti ...
-
刚刚找到解决方案。 在更新对象Rateio之前,必须合并(持久化)对象Rateio 。 我认为对象DetalheRateio作为Rateio子项将由JPA自动Rateio 。我的错误。所以,我手动合并每个DetalheRateio对象。我曾经这样做的snipet: List
novos = (List ) CollectionUtils.subtract(detalheRateios, detalheRateiosBd); List 简短的回答是,您可以将您的Seam 2.2应用迁移到JBoss AS 7。 主要挑战在于类加载,因为类加载如何通过AS 7完全重新构建。 我不是简单地通过这里的所有步骤,而是希望向您提供关于如何在示例应用程序(Seam预订应用程序)上完成这些操作的官方文档。 它提供了关于如何将Seam 2.x应用程序迁移到JBoss AS 7的分步指南,并指出了您将面临的一些问题以及如何处理它们。 指南位于此处 。 其他有用的参考 JBoss AS 7类加载 Seam 2 JPA示例 祝你好运! The short ans ...EJB进入SEAM组件(不同的项目和相同的JBoss)(EJB into SEAM Component (Different projects and same JBoss))[2022-10-18]
您的ComponentX类不是EJB,因此您无法使用@EJB注释来注入它们。 你有几个选择。 将ComponentX转换为EJB,添加@Stateless或@Statefull以及接口@Local或@Remote,这样AS会注意到ComponentX是一个EJB,并且知道如何处理所需的注入。 另一个选项是让ComponentX只是一个组件,并使用InitialContext#lookup手动获取对“beanA / remote”的引用。 Your ComponentX class is not an EJB ...您必须使用Seam 2扩展来在测试工作中通过@In进行注入 - https://github.com/arquillian/arquillian-extension-seam2 。 请记住,随着Seam 2不再处于活跃开发状态,扩展本身也不是。 You have to use Seam 2 extension to make the injection through @In in the test working - https://github.com/arquillian/arquillian-ext ...Hibernate坚持insertable=false,updatable=false rateId insertable=false,updatable=false因为rateId字段映射到用作与RateMaster实体关系的连接列的同一列。 因此,您已经引入了冗余,Hibernate无法承诺保留通过冗余引入的任何不一致的数据。 我的建议是只rateId字段。 通过分配给每个Subscription的RateMaster实体管理底层的列。 如有必要,在Subscription上引入一个只读,非持久访问器, ...Seam不需要Hibernate,最近的2.x版本经过测试并记录在其他应用程序服务器上。 我们有一个使用JPA的Seam应用程序,这对设置没有任何问题。 我不使用GlassFish,但Seam手册中有关于在GlassFish上部署JPA示例的部分,这听起来像您需要的内容。 Seam does not require Hibernate, and the recent 2.x releases are tested and documented to work on other application ser ...我不确定你的意思是“外键必须在OptIn中”。 您已通过@PrimaryKeyJoinColumn映射您的@OneToOne关联,这意味着您的实体将通过其ID值进行关联。 这也意味着: 您无法在@PrimaryKeyJoinColumn注释中指定列名称; 它们将取自两个实体的相应@Id列。 标记为LAZY是毫无意义的并且将被忽略; 可选的@OneToOne关联总是被热切地提取。 OptIn在这个关联中可选的唯一方法是如果数据库中没有给定ID的条目。 您使用的是何种Hibernate / Annotation ...在部署时共享错误消息会很有帮助。 Web应用程序(file.war)是否引用了不在file.war中的服务? 大多数项目都是作为耳朵部署的,因为ejb模块是单独打包的(参见下面的application.xml)。 看看运行它的原始JBoss 6服务器上的application.xml。 它可能除了war文件之外还有其他模块。我已经解决了这个问题。 我在persistence.xml中添加了以下类标记来解决问题,com.wachovia.apps.amaster.orm.Officer 标记的顺序在persistence.xml中很重要。 在我的例子中,必须在标记之前和 标记之后添加此类标记。 I have resolved the issue. I have added the the following class tag in per ... 相关文章
更多- HTML5 Web SQL Database 数据库
- MongoDB shell 操作数据库
- myEclipse8.5 New DataBase Connection Driver时出错
- 《Oracle Database 11g SQL开发指南》(Oracle Database 11g SQL )扫描版[PDF]
- 《Oracle Database 11g DBA手册》(Oracle Database 11g DBA Handbook )扫描版[PDF]
- 《数据库系统基础:初级篇(第5版)》(Fundamentals of Database Systems (5th Edition))扫描版[PDF]
- 《Oracle Database 10g DBA手册-管理健壮的、可扩展的、高可用的Oracle数据》(Oracle Database 10g DBA Handbook)扫描版[PDF]
- 《数据库系统基础:高级篇(第5版)》(Fundamentals of Database Systems (5th Edition) )扫描版[PDF]
- MongoDB: The Definitive Guide
- [Solr] (源) Solr与MongoDB集成,实时增量索引
最新问答
更多- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
- 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
- UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
- 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
- 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
- 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
- asp用javascript(asp with javascript)
- “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
- 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
- c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
- 以编程方式创建视频?(Create videos programmatically?)
- 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
- webform和mvc的区别 知乎
- 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
- 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
- iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
- 为什么开机慢上面还显示;Inetrnet,Explorer
- 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)