user1340582
user1340582

Reputation: 19739

Best practice to pass a Domain Class between Grails (Groovy) and Java classes?

I have a Grails service that calls a utility class written in Java. The Java utility class would need to use and manipulate the Domain Classes written in Grails, which are passed into it. Also eventually, the output needs to be a Domain Class in Grails and not a java object.

So basically: Grails Domain Class input -> manipulated by Java utility class -> Grails Domain Class output to Grails Service and forward to Controller.

What would be the best practice to handle the above? Should I write identical value objects in Java? I guess I cannot manipulate the Grails Domain Classes directly within the Java class?

Upvotes: 3

Views: 617

Answers (1)

chanwit
chanwit

Reputation: 3214

You can send it to Java classes directly.

One thing to note is that you should be aware of your objects detaching out of the current Hibernate session. If it's the case, you may require to attach it back (using merge() for example) to another Hibernate session before further proceed.

Upvotes: 2

Related Questions