有没有办法将属性从一个类的实例绑定到另一个类的实例的属性(两者之间的公共字段).请参阅以下示例:
class One {
String foo
String bar
}
class Two {
String foo
String bar
String baz
}
def one = new One(foo:'one-foo', bar:'one-bar')
def two = new Two()
two.properties = one.properties
assert "one-foo" == two.foo
assert "one-bar" == two.bar
assert !two.baz
Run Code Online (Sandbox Code Playgroud)
结果是一个错误:无法设置readonly属性:class的属性:Two
我正在编写一个Grails应用程序,该应用程序主要使用带有服务支持的端点的springws Web服务插件.这些服务将从各种后端数据库中检索数据(即,不通过域类和GORM).我想存储我的服务将用于获取外部文件中的Web服务数据的sql.我在寻找建议:
保存文件的最佳位置在哪里(即,我想将它们放在像grails-app/sql这样明显的地方)和最佳格式(即xml,configslurper等)
抽象检索sql文本的最佳方法,以便我将执行sql的服务不需要知道它们的获取位置和方式.服务将只提供一个sqlid并获取sql.