Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reuse Grails application's domain classes?

Tags:

grails

I have already create a Grails application. For some reasons I need to create another console application for someone to modify database data.

  1. Is it possible to package Grails application as a JAR library, so that the console application can reuse those domain classes?
  2. Or, I add/create some classes in Grails application and package it as a JAR and run as console application?
like image 781
Matthew Lai Avatar asked Jul 06 '11 15:07

Matthew Lai


2 Answers

If no better answer, probably I will use the batch-launcher plugin to do that.

like image 164
Matthew Lai Avatar answered Oct 17 '22 06:10

Matthew Lai


You can put the domain classes in a JAR and tell Grails that these are your domain classes by adding a Hibernate XML file (in grails-app/conf/hibernate) that refers to the classes in this JAR. You can use this JAR in any other Java/Groovy application, but obviously they'll only have the persistence methods (dynamic finders, save(), etc.) when used in a Grails app.

like image 40
Dónal Avatar answered Oct 17 '22 08:10

Dónal