Using GORM in a Groovy application
GORM is a data access toolkit originally created as part of Grails. It supports multiple database types. The following table summarizes the modules needed to use GORM, and links to documentation.
Dependency | Description |
---|---|
| Configures GORM for Hibernate for Groovy applications. See the Hibernate Support docs |
| Configures GORM for MongoDB for Groovy applications. See the Mongo Support docs. |
| Configures GORM for Neo4j for Groovy applications. See the Neo4j Support docs. |
Once you have configured a GORM implementation per the instructions linked in the table above you can use all features of GORM.
GORM Data Services can also participate in dependency injection and life cycle methods:
GORM Data Service VehicleService.groovy
@Service(Vehicle)
abstract class VehicleService {
@PostConstruct
void init() {
// do something on initialization
}
abstract Vehicle findVehicle(@NotBlank String name)
abstract Vehicle saveVehicle(@NotBlank String name)
}
You can also define the service as an interface instead of an abstract class to have GORM implement the methods for you.