Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We use Spring's @Configurable (along with regular new operator) which works like a charm. No more <a href="http://en.wikipedia.org/wiki/Anemic_Domain_Model" rel="nofollow noreferrer">anemic domain models</a>. Finally, this is much more object oriented design, isn't it:</p> <pre><code>Person person = new Person(firstname, lastname); // weird peopleService.save(person); // good (save is @Transactional) person.save(); Mail mail = new Mail(to, subject, body); // weird mailService.send(mail); // good (send is @Transactional) mail.send(); </code></pre> <p>We haven't done any performance comparison though. So far, we simply haven't felt the need to do so.</p> <p>EDIT: that's how the person class would look like:</p> <pre><code>@Configurable("person") public class Person { private IPersonDAO _personDAO; private String _firstname; private String _lastname; // SNIP: some constructors, getters and setters @Transactional(rollbackFor = DataAccessException.class) public void save() { _personDAO.save(this); } @Transactional(readOnly = true) public List&lt;Role&gt; searchRoles(Company company) void{ return _personDAO.searchRoles(this, company); } // it's getting more interesting for more complex methods @Transactional(rollbackFor = DataAccessException.class) public void resignAllRoles(Company company) { for (Role role : searchRoles(company)) { role.resign(); } } } // the implementation now looks like this personService.getPerson(id).resignAllRoles(company); // instead of this roleService.resignAll(personService.searchRoles(personService.getPerson(id), company)); </code></pre> <p>And that's the Spring config:</p> <pre><code>&lt;context:spring-configured /&gt; &lt;bean id="person" class="org.example.model.Person" lazy-init="true"&gt; &lt;property name="personDAO" ref="personDAO" /&gt; &lt;/bean&gt; </code></pre> <p>Note: as you see, there are still services around, e.g. to search for objects (personService.getPerson(id)) but all methods that operate on a passed object (e.g. a person) are moved to that class itself (i.e. person.save() instead of personService.save(person)). The method itself stays the same and works with any underlying data access layer (pure JDBC, Hibernate, JPA, ...). It has simply moved where it belongs.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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