Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of all domain classes in Grails

how can I get a list of alle domain classes I use in my project? Something like GORM.domains.list().

like image 516
Jan Avatar asked Apr 25 '10 09:04

Jan


People also ask

What is Grails domain class?

In Grails a domain is a class that lives in the grails-app/domain directory. A domain class can be created with the create-domain-class command: grails create-domain-class org.bookstore.Book. or with your favourite IDE or text editor.

How do I create a domain class in Grails?

If you don't specify a package (like "org. bookstore" in the example), then the name of the application will be used as the package. So if the application name is "bookstore" and you run create-domain-class Book , then the command will create the file grails-app/domain/bookstore/Book.

What is Grails Gorm?

GORM is the data access toolkit used by Grails and provides a rich set of APIs for accessing relational and non-relational data including implementations for Hibernate (SQL), MongoDB, Neo4j, Cassandra, an in-memory ConcurrentHashMap for testing and an automatic GraphQL schema generator.

What are Grails constraints?

Constraints in Grails are a way to declaratively specify validation rules. Most commonly they are applied to domain classes, however URL Mappings and Command Objects also support constraints.


1 Answers

Using

grailsApplication.getArtefacts("Domain")

you get a list of GrailsDomainClass instances that hold meta-information regarding the domain class. The domain class itself is returned by Calling getClazz(). In short:

grailsApplication.getArtefacts("Domain")*.clazz

returns a complete list of the existing domain classes.

like image 155
Stefan Armbruster Avatar answered Sep 28 '22 15:09

Stefan Armbruster