简体   繁体   English

grails / gorm / mysql /休眠

[英]grails/gorm/mysql/hibernate

I have a simples question. 我有一个简单的问题。 I have been trying to learn Grails by my own, and i managed to do a simple application using Grails/Gorm. 我一直在尝试自己学习Grails,并且设法使用Grails / Gorm做一个简单的应用程序。

1 ) Later, i decided to use Mysql instead of Gorm - i just needed to configure the 'DataSource' and download the driver. 1)后来,我决定使用Mysql代替Gorm-我只需要配置'DataSource'并下载驱动程序。

2 )So if i want to use hibernate between both (Grails and MYSQL) like this: http://www.grails.org/doc/latest/guide/15.%20Grails%20and%20Hibernate.html , i need to make an 'hibernate.cfg.xml' file, and specify my mysql database url, user, pw etc .. and i have to map each Class in Grails for MySql columns. 2)因此,如果我想在两个(Grails和MYSQL)之间使用休眠模式,例如: http : //www.grails.org/doc/latest/guide/15.%20Grails%20and%20Hibernate.html ,我需要一个“ hibernate.cfg.xml”文件,并指定我的mysql数据库url,用户,pw等..我必须在Grails中为MySql列映射每个类。

So what is the diference between 1) and 2) ? 那么1)和2)之间的区别是什么? and what exactly hibernate does. 以及冬眠到底是做什么的。 Give examples if possible 举例说明

PS. PS。 Please correct me if i said something wrong, im kinda new to this 如果我说错了,请指正我,这有点新

I think you are a bit confused here. 我觉得您在这里有些困惑。

GORM is not a database, it is a ORM that maps you Groovy classes to database tables. GORM不是数据库,而是将您的Groovy类映射到数据库表的ORM。 It uses Hibernate under the covers to achieve this (Hibernate is also an ORM). 它使用Hibernate来实现此目的(Hibernate还是ORM)。

The default database Grails uses is an in-memory HSQL DB. Grails使用的默认数据库是内存中的HSQL DB。 If you want to use MySQL instead of that, all you need to do is change the settings in conf/DataSource.groovy. 如果要使用MySQL而不是MySQL,只需更改conf / DataSource.groovy中的设置即可。

You don't need to create any Hibernate xml files. 您不需要创建任何Hibernate xml文件。 That part of the documentation you've linked to is to allow people with existing Hibernate domain models to easily re-use them. 您链接到的文档的那一部分是允许具有现有Hibernate域模型的人员轻松地重用它们。

Hope this helps clear things up. 希望这有助于清理问题。

cheers 干杯

Lee 背风处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM