4
votes

Found some partial answers to the below scenario but require further clarification.

Have the following situation:

  • domain classes written in java
  • the domain classes are not mapped to a DB through hibernate
  • the java classes are used by a java server which simply performs intensive computations before returning result to client as a serialized java class

What I would like to do:

create a grails application which could do the following:

  1. use the java domain classes as grails domain classes
  2. have the java domain classes mapped to DB by GORM
  3. be able to create the java domain class from the groovy domain class in order to be able to send it to the java server for processing and then receive the java class response and transform it to groovy class in order to store in DB with GORM mapping
  4. basically have a grails application handle the user interaction and manage the object persistence for the external java server that processes the java classes

From the following post (Using Java beans as Grails domain classes) I see that the java domain classes can be used in grails by simply defining constraints, but this is if the classes are mapped with hibernate. In my case I want the classes to be mapped by GORM.

Solution:

  • i was thinking about writing an equivalent groovy domain model for the java domain model. This however seems like a lot of work and modification to the java class will have to be replicated in the groovy classes.
  • then i would need to write function to create the java class from the groovy class in order to pass the java class to the java processing server, and vice versa.

All suggestions to implement the above scenario are welcome.

Thanks.

1

1 Answers

3
votes

I haven't tried this, but from the documentation that you pointed to, it looks like you could:

  1. Create hibernate xml mappings for your Java objects
  2. Use your Java objects (with hibernate mappings) in your Grails project
  3. Add Gorm constraints in UserBeanConstraints.groovy