- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要一些有关API的帮助,当我在网络上时,订单保存正确,但是在API上时,一切都会出错:
def test = parseJSON.sort { a, b -> a.ID <=> b.ID } //or dateTime, will print the same
//order when I print each of them
[IDWeb:0, conductivity:0, ReportId:2, dissolvedOxygen:0, levelWater:1, ID:1, ph:0, redoxPotential:0, temperature:0]
[IDWeb:0, conductivity:0, ReportId:2, dissolvedOxygen:0, levelWater:0, ID:2, ph:0, redoxPotential:0, temperature:0]
[IDWeb:0, conductivity:0, ReportId:2, dissolvedOxygen:0, levelWater:0, ID:3, ph:0, redoxPotential:0, temperature:0]
[IDWeb:0, conductivity:0, ReportId:2, dissolvedOxygen:0, levelWater:4, ID:4, ph:0, redoxPotential:0, temperature:0]
test.each{
def sample = new SampleWater()
sample.levelWater = it.levelWater
sample.conductivity = it.conductivity
sample.dissolvedOxygen = it.dissolvedOxygen
sample.redoxPotential = it.redoxPotential
sample.ph = it.ph
sample.temperature = it.temperature
water.addToSamples(sample)
}
return water
addTo
没有按顺序保存。我该如何解决?
最佳答案
确保已在List
域类中将样本类型定义为Water
,以便我们可以维护插入顺序:
class Water {
static hasMany = [samples: Sample]
List<Sample> samples = []
}
class Sample {
def levelWater
}
hasMany
的实现为
Set
类型,它不维护插入顺序,但负责唯一性。
关于grails - 如何按给定日期/编号顺序保存addTo?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34276989/
我正在遵循 Grails in Action 中的示例。我有一个问题,如何理解 addTo*()功能有效。 我有一个简单的域:具有以下关系的用户、帖子、标签: 用户1对M发帖 用户一对一标签 发布 M
为什么这段代码不能正常工作? def classeInstrumento = classeInstrumentoService.getClasseInstrumento("value") def in
我正在使用grails控制台来处理我的关系。我正在使用Grails in Action书中的练习: 我有关系: class User { ... Profile profile
我建立了以下关联: class Applicant { String appStepsComplete String name String eNumber Strin
在使用 Grails 域类时遇到问题。我正在覆盖构造函数以从 net.sf.json.JSONObject 构建域类对象。当我通过 Controller 实例化一个对象时,这很好用。然后我尝试通过测试
当一个新对象被添加到具有 hasMany 关系的域时,我想做一些工作。 例如,对于 Person hasMany Hobby在拦截器中为 addToHobby() 做一些工作和 removeFromH
我正在使用Grails 2.5.5,这里有一个简单的场景:A有很多B。 因此,我有一种事务性服务方法,该方法主要执行以下操作: A a if (isNew) { a = new A() } e
我正在做一个阅读故事的网站。我的目标是将故事的内容保存到几页中以获取列表,然后轻松地对其进行分页;我做了以下事情: 在域中我创建了两个域,Story : class Story { Strin
我正在尝试将 Grails 中的 addTo* 方法用于另一个类。这些类具有多对多的关系。我已经在第一个类中定义了 hasMany.. static hasMany = [operators: Ope
在我的 Grails 应用程序中,我非常兴奋地使用了一些技术,但最近我遇到了一些性能问题,我将描述我的情况: 一张表包含 400 万以上的数据; 我正在使用事件总线 API; Grails 2.2.3
我有一个非常简单的 hasMany 关系,其中“产品”有许多“包”。我正在运行一个脚本来尝试填充数据,它在第一次运行时运行良好。然而,在第二次运行时,它开始输入重复项,我虽然这对于 hasMany 是
是否可以在 Grails 中对 addTo* 函数进行单元测试? 感谢您的帮助。 最佳答案 文档 says in section 9.1 : In Grails you need to be part
在文档some examples中有一个对save的调用,而some others没有。我假设addTo*需要调用save,而removeFrom*不需要。我错了吗? 最佳答案 在大多数情况下,两者都
我想向 User 类添加订阅,我通过调用“addTo”方法来实现,这是我的代码: if (params.jobs == "on") { user.addToSubscriptions(
我有两个域类:用户 class User { String username String password String email Date dateCreated
我有2张 table 预订嘉宾 预订有一个 FK 给客人 (GuestId) 当我添加一个新的预订时,我必须在两个对象上调用 AddTo 才能工作。这很好,但我想我应该能够在 Reservation
我有域类: class MarketCommoditiesConfiguration extends MarketConfiguration { static mapWith = "mongo
假设我定义了一个变量列表 {a,b,c} = {1,2,3} 如果我想将它们加倍,我可以这样做: {a,b,c} *= 2 变量 {a,b,c} 现在计算为 {2,4,6}。如果我想对它们应用任意转换
我在 grails 和 mysql 中有 2 个表 说A和B 我想在这里实现的场景是: (1)A 的实例可以有零个/一个/多个 B 的实例。 (2)当实例A被删除时,其所有相关的B也必须被删除。 (3
我是 Grails 的新手,我需要在“有很多”属性发生变化时进行一些计算,我认为最好的地方是在属性的 setter 中,因为我的属性是一个列表最好的地方应该在 addTo 和 removeFrom 方
我是一名优秀的程序员,十分优秀!