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

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

问题描述

为了解决这个问题,我必须将这样的类移动到src / groovy。将所有域模型类都放在域目录中,而不是将它们分割出来是很好的做法。



更新1:
这是一个受欢迎的 a>(寻找GRAILS-2515)请求的功能在Grails Jira页面上。如果有人对此功能感兴趣,您可以此处进行投票和跟踪。



GRAILS-2515上的更新: static mapWith =none应该在1.3.5中实现。

解决方案

只能将域对象上的某些属性标记为transient,以便它们不会持久存在数据库中。否则,所有域对象都会被保留。



更新

Grails 1.3.5发布(2010年10月4日发布),现在现在有可能禁用域类的持久性。将以下内容添加到域类:

  static mapWith =none

有一个 JIRA票的详细信息。


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.

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.

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.

UPDATE

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"

There is a JIRA ticket with further details.

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

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