- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我在下面有这个查询,它可以工作,但是我想避免显式地编写HQL并使用Grails / GORM中可用的方法。我该如何实现?
我有一个包含许多RSVP(每个人1个)的 Activity 。该查询正在查找特定用户尚未针对哪些事件进行rsvp。它根据user_id左连接Rsvp表和事件表。我检查Rsvp是否为空。
def events = Event.executeQuery("""
SELECT event
FROM Event AS event
LEFT JOIN event.rsvps AS rsvp
WITH rsvp.user.id = ?
WHERE event.active = 1
AND event.startDate >= ?
AND rsvp.id IS NULL
""", [(long)1, new Date().clearTime()]);
最佳答案
有一个近似值。我怀疑LEFT OUTER JOIN是否可以使用,但应该可以给您一个想法:
import static org.hibernate.sql.JoinType.*
def events = Event.withCriteria {
createAlias('rsvps', 'r', LEFT_OUTER_JOIN)
// I'm not sure about the following line. Aliases change things a bit
// Besides, it conflicts with the isNull().
eq('r.user.id', 1)
eq('active', 1)
ge('startDate', new Date().clearTime())
isNull('r.id')
}
关于grails - 如何使用内置的Grails/GORM方法表示此查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37599681/
我在使用 Go 进行应用程序开发,我使用 gorm 库连接到数据库。我看到 gorm 有 2 个库 github.com/jinzhu/gorm和 gorm.io/gorm . 我不知道该用哪个。它们
我是 Gorm 的新手。我正在尝试进行级联删除,如果我删除一个用户,则与该用户关联的角色(属于)、个人资料(有一个)和书籍(一对多)也将被删除。 我在下面设置了我的模型,但级联似乎不起作用。当我删除我
使用 Jinzhu 的 GORM 包,顺便说一句,我现在有这个结构: type User struct { gorm.Model // The Users username U
Golang 的 GORM 库支持复合主键。但是如何从相关模型中引用它们呢? 例如,假设我有一个 User 和一个 Note 模型: type User struct { Organizati
我正在尝试使用 Grails 项目作为插件,基本上将我的域类放在插件中,然后在多个 Grails 项目中使用它们。 我已经这样做了: grails 创建应用程序网页 grails 创建应用程序插件 在
Golang 的 GORM 库支持复合主键。但是如何从相关模型中引用它们呢? 例如,假设我有一个 User 和一个 Note 模型: type User struct { Organizati
如何省略来自 gorm.Model 的列。例如。创建日期、修改日期。 考虑以下模型: type User struct{ gorm.Model Firstname string
当我在 Grails 中执行 domainObj1 == domainObj2 时,对象是按 ID 进行比较的吗?如果不是,如何比较? 最佳答案 首先,您需要了解 GORM/Grails 在 equa
目前正在为此苦苦挣扎。 我希望能够使用抽象域类来使我能够使用一些通用代码来执行一些常用操作。 我的问题是很多 GORM 操作都是域类上的静态方法,这使得它变得困难。想知道这些方法是否有任何非静态等价物
我有一个结构/模型 type User struct { gorm.Model Name string `gorm:"unique;not null"
我想创建一组在我的应用程序中使用的 gorm 类型。所以我想用我的类型定义一个 map gorm.DB作为键和空的结构{}作为标志: var ( autoMigrations map[gorm
有表 customer_account (postgres) 是从 YII2 迁移过来的。 数据链接: CREATE TABLE public.test_table ( id INTEGER PR
我有一个域对象,它已经有一个名为 versions 的属性,所以我想给内置的 version 属性一个不同的名称(在 GORM 中用于乐观锁定)。例如,我想将其称为 updateCount。 请注意,
我有一个普通的 Grails 3.3.2 应用程序。我可以使用 gradle testintegrationTest 很好地运行测试。但是,当我尝试右键单击并在 IntelliJ 中运行测试类或单个测
除了这样做对性能的明显影响之外,还有什么好的技术原因 不是 设置 grails.gorm.autoFlush = true和 grails.gorm.failOnError = true在 Confi
GORM 似乎不尊重我基于外键关联表的尝试,而我的主键关联有效。 我有 3 个结构,它们与 3 个单独的数据库表相关联。它们的关系如下: Inventory.CustID 与 Customer.Cus
我有一个像这样的 golang 结构的表: Order { ID TransactionID Transaction } Transaction { ID ProfileID
我正在使用 Gorm,对如何从模型中检索嵌套的 SubComments 有一些疑问。我遇到的问题是评论嵌套了两层深,即 Comment.SubComments 没有加载。我是否遗漏了 Preload
我正在尝试使用 golang gorm 创建一个自我引用的一对多关系。每个用户可以创建多个其他用户 (Created),但一个用户始终由另一个用户创建 (UserID)。 type User stru
假设我有 2 个表,它们共享一些列名,例如: table_1 - id - created_at - deleted_at - name - color table_2 - id - created_
我是一名优秀的程序员,十分优秀!