Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not a Java expert, but I use NHibernate in my .NET code so my experience should be directly translatable to the Java world.</p> <p>When using ORM (like Hibernate you mentioned) to build Domain-Driven Design application, one of good (I won't say best) practices is to create so-called application services between the UI and the Domain. They are similar to stateless business objects you mentioned, but should contain almost no logic. They should look like this:</p> <pre><code>public void SayHello(int id, String helloString) { SomeDomainObject target = domainObjectRepository.findById(id); //This uses Hibernate to load the object. target.sayHello(helloString); //There is a single domain object method invocation per application service method. domainObjectRepository.Save(target); //This one is optional. Hibernate should already know that this object needs saving because it tracks changes. } </code></pre> <p>Any changes to objects contained by DomainObject (also adding objects to collections) will be handled by Hibernate.</p> <p>You will also need some kind of AOP to intercept application service method invocations and create Hibernate's session before the method executes and save changes after method finishes with no exceptions.</p> <p>There is a really good sample how to do DDD in Java <a href="http://dddsample.sourceforge.net/" rel="nofollow">here</a>. It is based on the sample problem from Eric Evans' <a href="http://rads.stackoverflow.com/amzn/click/0321125215" rel="nofollow">'Blue Book'</a>. The application logic class sample code is <a href="http://dddsample.svn.sourceforge.net/viewvc/dddsample/branches/1_1_x/dddsample/src/main/java/se/citerus/dddsample/application/impl/BookingServiceImpl.java?revision=436&amp;view=markup" rel="nofollow">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      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