Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Before I start answering your question, let me question you domain model. Base class is generally fine, but I want to talk about Person and Customer. You may have good reasons why you picked up inheritance, but please think of composition. Maybe you could have Person that contains a reference to an enum, that states type of the person. You could start here with that: <a href="http://en.wikipedia.org/wiki/Composition_over_inheritance" rel="nofollow">http://en.wikipedia.org/wiki/Composition_over_inheritance</a> </p> <ol> <li><p>I think you have a typo there. Call save() method on 'customer' not 'Customer', which is a class</p></li> <li><p>When there is a request coming to Grails application, it opens a session and the session is available during that request. There is not this kind of behavior like that in Vaadin. You need to put it into a Service. Yes, you can make generic service to save an object</p> <p>class GenericService { def save(def domain) { domain.save(failOnError:true) }} </p></li> <li><p>You can get the session factory like this </p> <p>import org.codehaus.groovy.grails.commons.ApplicationHolder as AH</p> <p>def ctx = AH.application.mainContext def sessionFactory = ctx.sessionFactory</p> <p>or ApplicationContext applicationContext = grailsApplication.mainContext ConfigurableLocalSessionFactoryBean factory = applicationContext.getBean('&amp;sessionFactory')</p></li> <li><p>As I wrote, you could create GenericService or a service per domain object. Just to keep in mind that GenericService should only save an object and contain no other logic that would be specific for a domain object.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload