Is it possible in grails to disable persistence of a domain class?

岁酱吖の 提交于 2019-12-01 03:36:55

问题


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.


回答1:


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.




回答2:


If I might add 2 words to your question: against convention! Grails is all about convention over configuration and doing what you'd like to do is against it.




回答3:


No. It is not.



来源:https://stackoverflow.com/questions/3795700/is-it-possible-in-grails-to-disable-persistence-of-a-domain-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!