grails 域类是否必须绑定到数据库? [英] Do grails domain classes have to be tied to a database?

查看:15
本文介绍了grails 域类是否必须绑定到数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说到 grails,我是一个完全的菜鸟(而且在谈到 groovy 时仍然非常菜鸟)所以如果这是一个愚蠢的问题,我深表歉意.

I am a complete noob when it comes to grails (and still very noobish when it comes to groovy) so I apologise if this is a dumb question.

我正在构建一个简单的 Web 应用程序,我想根据文件系统对象(即目录结构和文件类型)而不是数据库数据来控制我的应用程序中域的部分内容.这样做有多容易,或者域对象与 GORM 纠缠在一起以至于不值得努力尝试?

I am building a simple web app and I want to control portions of the domain in my app based on file system objects (i.e. directory structure and file type) rather than database data. How easy is it to do this or are the domain objects so entwined with GORM that it is not worth the effort to try?

推荐答案

几周前我自己也遇到了这个问题.

I ran into this question myself a couple of weeks ago.

您只需将以下代码段添加到 Domain Class.

You can just add the following snippet to the Domain Class.

def isAttached() 
{
   return false
}

现在它没有连接到您的数据库.瞧!

Now it isn't connected to your database. Voila!

这篇关于grails 域类是否必须绑定到数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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