我如何在Grails中复制域对象? [英] How can I duplicate a domain object in Grails?

查看:114
本文介绍了我如何在Grails中复制域对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个域对象的副本。什么是最简单的方法来实现这一点?

I want to make a copy of a domain object. What is the simplest way to accomplish this?

我意识到我可以创建一个新记录,然后遍历每个字段复制数据字段的字段 - 但我认为必须有一个更简单的方法来做到这一点...

I realize I could create a new record, and then iterate over each of the fields copying the data field-by-field - but I figured there must be an easier way to do this...

在Rails中,有一个简单的方法可以做到这一点:

In Rails there is a simple way to do this:

#rails < 3.1
new_record = old_record.clone

#rails >= 3.1
new_record = old_record.dup

Grails中是否有任何等价物?

Is there any equivalent in Grails?

推荐答案

没有。已经要求 http://jira.grails.org/browse/GRAILS-3532 。有人在该问题上添加了一些代码,可能对您有所帮助。

There is not. It has been requested http://jira.grails.org/browse/GRAILS-3532. Someone has added some code to that issue that might be helpful to you though.

这篇关于我如何在Grails中复制域对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆