是否可以在 grails 中禁用域类的持久性? [英] Is it possible in grails to disable persistence of a domain class?

查看:30
本文介绍了是否可以在 grails 中禁用域类的持久性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了解决这个问题,我必须将这些类移动到 src/groovy.最好将我所有的域模型类放在域目录中,而不是将它们拆分.

To get around this I have to move such classes to src/groovy. It would be nice to have all of my domain model classes in the domains directory rather than split them up.

更新 1:这是一个流行(查找 GRAILS-2515)在 Grails Jira 页面上请求的功能.如果有人对此功能感兴趣,您可以在此处投票和跟踪它.

Update 1: This is a popular (look for GRAILS-2515) requested feature on the Grails Jira page. If anyone is interested in this feature you can vote and track it here.

关于 GRAILS-2515 的更新:static mapWith = "none" 应该在 1.3.5 中起作用.

Update on GRAILS-2515: static mapWith = "none" should do the trick in 1.3.5.

推荐答案

只能将域对象上的某些属性标记为瞬态",这样它们就不会持久化到数据库中.否则,所有域对象都将被持久化.

It is only possible to mark certain properties on the domain object as 'transient' so that they are not persisted to the database. Otherwise, all domain objects are persisted.

更新

在最新版本的 Grails 1.3.5(2010 年 10 月 4 日发布)中,现在可以禁用域类的持久性.将以下内容添加到域类:

With the most recent release of Grails 1.3.5 (released Oct 4 2010) it is now possible to disable persistence of a domain class. Add the following to the domain class:

static mapWith = "none"

有一个 JIRA 票,其中包含更多详细信息.

There is a JIRA ticket with further details.

这篇关于是否可以在 grails 中禁用域类的持久性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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