简体   繁体   中英

How to use the eclipse Hibernate Tools with grails and MySQL

I've managed to connect from eclipse Hibernate Tools to my MySql Database used with grails, classes mapped by GORM.

Now I'd like to perform HQL queries on the DB using the Hibernate Tools. However Hibernate Tools tells me for every table that it is not mapped.

My question: Do I really need to write all the class mappings manually into a hibernate.cfg.xml file or is there a way to get it from grails? I mean grails / GORM needs to have an idea about the mappings, right? Or am I going for this the wrong way?

PS I know there is a script grails-create-hibernate-cfg-xml, but this only creates a dummy file for some Books class...

Grails has convetions based config so there is no hibernate.cfg.xml but you can easily execute HQL queries int groovy console - just call

grails console

It will open Groovy console connected to your app so you can write groovy scripts interacting with your DB.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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