我有一個域類UserProfile,它與另一個域類User具有一對一的關係。提供了域的結構。Grails;如何在本機SQL查詢中引用域屬性
сlass UserProfile {
String fio
String position
String phone
String email
static belongsTo = [user: User]
static constraints = {
// some constraints
}
static mapping = {
//some mapping; user property is not mapped
}
我需要寫Grails中爲用戶配置域名原生SQL查詢,我不知道如何引用用戶屬性(靜態屬於關聯= [用戶:用戶])。我嘗試過USER_ID,但它不起作用。 我無法直接使用映射部分命名該列;我只需要了解UserProfile域中的user列如何在數據庫中命名,以及如何在本機sql查詢中調用它。
如果您只需要查看模式細節,然後運行'grails schema-export',則會生成目標爲/ ddl.sql的模式。 http://grails.org/doc/2.2.1/ref/Command%20Line/schema-export.html – ikumen