Hibernate - 如何手动生成id?(Hibernate - how to generate id manually?)
我正在从Java中的一个数据库迁移到一个新数据库。 我的一个问题是我必须保持实体的相同id值。
我知道可以更改id生成器,但我需要手动设置id。 我使用从旧对象映射到新对象创建的每个实体,我只是设置值。 我不能手动设置像:
Map<String, Object> newEntity = new HashMap<String, Object>() newEntity.setId(oldEntity.get("id"))
I am working on data migration from one db to a new one in Java. One of my issues are that I must keep the same id values of the entities.
I know it's possible to change the id generator, but I need to set the id manually. Each entity I create using Map from old object to a new one and I just set values. can't I just set manually something like:
Map<String, Object> newEntity = new HashMap<String, Object>() newEntity.setId(oldEntity.get("id"))
原文:https://stackoverflow.com/questions/36550347
更新时间:2023-03-28 07:03
最满意答案
在Eclipse和Maven中我都不知道这样的事情(你需要像maven-clirr-plugin这样的东西来做一些接近的事情)。
I'm not aware of such a thing in neither Eclipse nor in Maven (you'd need something like the maven-clirr-plugin to do something approaching).
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
为了尝试使用JarSplice我成功解决了这个问题。 看完之后: 它不会按照您当前尝试的方式工作,因为您需要将jar文件放在jar旁边并通过'-Djava.library.path'参数指向它们。 如果您只想要一个jar并且想要避免命令行和本机文件的麻烦,请使用JarSplice工具。 JarSplice易于使用,并会自动为您处理本机文件。 1)只需将项目(类和资源)导出到jar(更容易通过IDE执行)。 2)然后运行JarSplice,将所需的所有罐子添加到jar选项卡(你的app jar,lwjgl.j ...
-
您可以尝试CTRL +单击没有附加源的类(在编辑器中这样做)。 当它显示一些有关该类的信息时,您将看到指导附加源对话框的按钮。 单击它并在弹出的对话框中选择您的类的源/ javadoc位置。 您还可以从项目构建路径设置中提到:选择库选项卡,展开所需的库(jar),并提供选择:源附件,javadoc附件,本机库位置等。您只需选择无论您想要什么,并编辑其当前设置。 或者你可以做@JB Nizet说... You can try to CTRL + click on a class that has no sou ...
-
eclipse有一个常春藤插件: http://ant.apache.org/ivy/ivyde/ 一个令人困惑的想法是使用groovy生成Eclipse .project和.classpath文件: 使用Apache Ivy和netbeans There is an ivy plugin for eclipse: http://ant.apache.org/ivy/ivyde/ A whackier idea is to use groovy to generate the Eclipse .projec ...
-
如果你不修改源代码,如果每个jar的源代码位于它自己的源代码jar中,性能会更好。 通常也更方便。 在这一点上这是一个约定 - 特别是如果你可以从一个Maven仓库获取罐子。 每个jar应该像你期望的那样组织起来,顶层目录是“org”,“com”等。在构建路径中,你可以附加一个源jar到每个二进制jar。 If you're not modifying the source, performance will be better if the source for each jar is in its ow ...
-
在Eclipse 3.7(Indigo)中,m2eclipse被更新并重命名,但是war插件的行为没有改变imo: 只需打开您的pom.xml并检查依赖项部分。 您的java项目不应该是“可选的”,也不应该是“提供的”依赖项。 此处描述了war插件的行为。 您可以激活“解析工作区依赖项”,但您的“普通”Java项目也应该有一个pom。 如果你的战争的maven构建失败(仔细检查),你应该在你的另一个项目中调用“install”(或者你可以手动为它安装一个jar,如果你不想为它制作一个pom.xml)。 In ...
-
在Eclipse和Maven中我都不知道这样的事情(你需要像maven-clirr-plugin这样的东西来做一些接近的事情)。 I'm not aware of such a thing in neither Eclipse nor in Maven (you'd need something like the maven-clirr-plugin to do something approaching).
-
将第三方库放在项目的lib文件夹中。然后使用
system 将它们添加到mavencom.example mylib 1.0 system ${basedir}/lib/mylib.jar 罐子发布在p2存储库中 。 http://download.eclipse.org/datatools/updates content.jar文件描述了repo,实际的jar文件位于http://download.eclipse.org/datatools/updates/plugins http://maven.eclipse.org/nexus/index.html上有一个nexus实例,其中包含一些sqltools jar,但是将maars发布到maven.eclipse.org仍在建设中。 The ...相关文章
更多- hibernate id 生成策略及主要使用方法
- 分布式ID生成器【snowflake雪花算法】
- 关于hibernate的saveorupdate
- 配置solr自动生成id
- solr4.0 id 自动生成
- 求高手帮我看看这个hibernate的问题啊!
- MongoDB _id和ObjectId详解
- solr required field: id
- js 通过td的id值 如何拿到tr的id值?
- Hibernate马士兵
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。