<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en" xml:base="http://www.olivergierke.de/wordpress/wp-atom.php">
	<title type="text">Soul Power</title>
	<subtitle type="text">www.olivergierke.de</subtitle>

	<updated>2010-07-15T23:03:46Z</updated>
	<generator uri="http://wordpress.org/" version="2.9.2">WordPress</generator>

	<link rel="alternate" type="text/html" href="http://www.olivergierke.de/wordpress" />
	<id>http://www.olivergierke.de/wordpress/feed/atom/</id>
	

			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/olivergierke/soulpower" /><feedburner:info uri="olivergierke/soulpower" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
		<author>
			<name>Oliver Gierke</name>
						<uri>http://www.olivergierke.de</uri>
					</author>
		<title type="html"><![CDATA[DDD Specifications with Hades]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/olivergierke/soulpower/~3/agJuwZpZKQE/" />
		<id>http://www.olivergierke.de/wordpress/?p=513</id>
		<updated>2010-07-15T23:03:46Z</updated>
		<published>2010-07-15T23:03:46Z</published>
		<category scheme="http://www.olivergierke.de/wordpress" term="Hades" /><category scheme="http://www.olivergierke.de/wordpress" term="coding" /><category scheme="http://www.olivergierke.de/wordpress" term="domain driven design" /><category scheme="http://www.olivergierke.de/wordpress" term="events" /><category scheme="http://www.olivergierke.de/wordpress" term="hades" /><category scheme="http://www.olivergierke.de/wordpress" term="java" /><category scheme="http://www.olivergierke.de/wordpress" term="opensource" />		<summary type="html"><![CDATA[Two weeks ago, I attended Java Forum Stuttgart, a really nice one-day conference to hear interesting talks, meet fellow developers and colleagues. The first talk I attended was held by Adrian Hummel and Mischa Kölliker entitled Rich domain model with JPA 2.0. As I am currently working on the final features for Hades 2.0 which [...]]]></summary>
		<content type="html" xml:base="http://www.olivergierke.de/wordpress/2010/07/ddd-specifications-with-hades/">&lt;p&gt;Two weeks ago, I attended &lt;a href="http://www.java-forum-stuttgart.de" target="_blank" title="Java Forum Stuttgart"&gt;Java Forum Stuttgart&lt;/a&gt;, a really nice one-day conference to hear interesting talks, meet fellow developers and colleagues. The first talk I attended was held by &lt;a href="http://adrianhummel.wordpress.com/" target="_blank" title="Adrian Hummel's blog"&gt;Adrian Hummel&lt;/a&gt; and Mischa Kölliker entitled &lt;a href="http://www.java-forum-stuttgart.de/abstracts.html#D1" target="_blank" title="Rich domain model with JPA 2.0"&gt;Rich domain model with JPA 2.0&lt;/a&gt;. As I am currently working on the final features for Hades 2.0 which will be based on JPA 2.0, I was eager to see what they were about to present.&lt;span id="more-513"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;One part of their talk was dealing with the specifications concept of the &lt;a href="http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215/ref=sr_1_1?ie=UTF8&amp;#038;s=books-intl-de&amp;#038;qid=1279234366&amp;#038;sr=8-1" target="_blank" title="Domain Driven Design @ Amazon"&gt;Domain Driven Design&lt;/a&gt; book by Eric Evans. &lt;code&gt;Specification&lt;/code&gt;s are an abstraction over a statement or requirement you can formulate for an entity. Each of the specifications you can define evaluates to a &lt;code&gt;boolean&lt;/code&gt;, so it can be regarded as predicate over the entity. The example Adrian gave in his talk (and also in a &lt;a href="http://adrianhummel.wordpress.com/2010/07/02/composed-specifications-using-jpa-2-0/" target="_blank" title="Adrian Hummel on Specifications"&gt;blogpost&lt;/a&gt; he dropped a few days later) is a soccer player, who can be characterized as &amp;#8220;fair player&amp;#8221; or as &amp;#8220;bonus eligible&amp;#8221;.&lt;/p&gt;
&lt;p&gt;JPA 2.0 introduces a criteria API, that effectively allows to define queries via a more or less typesafe API. So the typical code you write using this API looks as follows (code originally coined by Adrian):&lt;/p&gt;
&lt;pre name="code" class="java"&gt;CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery&amp;lt;Player&amp;gt; q = cb.createQuery(Player.class);
Root&amp;lt;Player&amp;gt; player = q.from(Player.class);

q.where(/** Build your where clause here **/);

return em.createQuery(q).getResultList();&lt;/pre&gt;
&lt;p&gt;As you see there&amp;#8217;s a few lines of boilerplate code that works with the domain class. The part that actually varies from query to query is the where clause you hand to the &lt;code&gt;q.where(…)&lt;/code&gt; method. What Adrian and Mischa now proposed is introducing a &lt;code&gt;Specification&amp;lt;T&amp;gt;&lt;/code&gt; interface that simply provides a callback method that gets the &lt;code&gt;CriteriaBuilder&lt;/code&gt;, &lt;code&gt;CriteriaQuery&amp;lt;T&amp;gt;&lt;/code&gt; and &lt;code&gt;Root&amp;lt;T&amp;gt;&lt;/code&gt; and reduces that to a JPA Predicate which can be handed to the &lt;code&gt;q.where(…)&lt;/code&gt; method then (code originally coined by Adrian):&lt;/p&gt;
&lt;pre name="code" class="java"&gt;public interface Specification&amp;lt;T&amp;gt; {

 Predicate toPredicate(CriteriaBuilder cb,
   CriteryQuery&amp;lt;T&amp;gt; q, Root&amp;lt;T&amp;gt; root);
}&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Specifications in Hades&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To make this available in Hades we simpy add a method &lt;code&gt;readAll(Specification&amp;lt;T&amp;gt; spec)&lt;/code&gt; to &lt;code&gt;GenericDao&lt;/code&gt; interface and &lt;code&gt;GenericJpaDao&lt;/code&gt; implementation and implement it as follows:&lt;/p&gt;
&lt;pre name="code" class="java"&gt;public List&amp;lt;T&amp;gt; readAll(Specification&amp;lt;T&amp;gt; spec) {
  CriteriaBuilder cb = em.getCriteriaBuilder();
  CriteriaQuery&amp;lt;T&amp;gt; q = cb.createQuery(getDomainClass());
  Root&amp;lt;T&amp;gt; player = q.from(getDomainClass());

  q.where(spec.toPredicate(cb, q, root);

  return em.createQuery(q).getResultList();
}&lt;/pre&gt;
&lt;p&gt;So what this gains you is a possibility to simply add new &lt;code&gt;Specification&lt;/code&gt; implementations and thus &amp;#8220;extend&amp;#8221; the DAO without the need to add finders e.g.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;One more thing&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The really cool part about the &lt;code&gt;Specification&lt;/code&gt;s is, that &amp;#8211; as you can concatenate JPA &lt;code&gt;Predicate&lt;/code&gt;s with &lt;code&gt;and&lt;/code&gt; and &lt;code&gt;or&lt;/code&gt; &amp;#8211; you can do this with some minor effort on the &lt;code&gt;Specification&lt;/code&gt;s, too. I added a small class that provides some syntactical sugar to make something like this possible:&lt;/p&gt;
&lt;pre name="code" class="java"&gt;playerDao.readBySpecification(
  where(isFair()).and(isEligibleForBonus()));&lt;/pre&gt;
&lt;p&gt;This probably needs some explaination. First, &lt;code&gt;isFair()&lt;/code&gt; and &lt;code&gt;isEligibleForBonus()&lt;/code&gt; are static methods on a (for example) &lt;code&gt;PlayerSpecifications&lt;/code&gt; class that return a &lt;code&gt;Specification&lt;/code&gt; instance creating the JPA &lt;code&gt;Predicate&lt;/code&gt; instance. The &lt;code&gt;where(…)&lt;/code&gt; method is also a static one on a helper class that pretty much returns itself, implements &lt;code&gt;Specification&lt;/code&gt; in turn and and provides the concatenation methods to chain &lt;code&gt;Specification&lt;/code&gt;s and build new &lt;code&gt;Specification&lt;/code&gt;s on the fly. Thus you can easily implement atomic predicates for the entity and build more complex expression from it &amp;#8211; a really cool complement to the finder methods already available in Hades. The feature will be available in upcoming RC3 of Hades 2.0 and can already be used with the current snapshots.&lt;/p&gt;
&lt;p&gt;A big thank you to Adrian and Mischa for a huge part of this new feature =).&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/olivergierke/soulpower/~4/agJuwZpZKQE" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://www.olivergierke.de/wordpress/2010/07/ddd-specifications-with-hades/#comments" thr:count="1" />
		<link rel="replies" type="application/atom+xml" href="http://www.olivergierke.de/wordpress/2010/07/ddd-specifications-with-hades/feed/atom/" thr:count="1" />
		<thr:total>1</thr:total>
	<feedburner:origLink>http://www.olivergierke.de/wordpress/2010/07/ddd-specifications-with-hades/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Oliver Gierke</name>
						<uri>http://www.olivergierke.de</uri>
					</author>
		<title type="html"><![CDATA[Hades &#8211; standing on the shoulders of giants]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/olivergierke/soulpower/~3/q680pum3Dyk/" />
		<id>http://www.olivergierke.de/wordpress/?p=500</id>
		<updated>2010-07-01T18:56:02Z</updated>
		<published>2010-06-30T19:40:18Z</published>
		<category scheme="http://www.olivergierke.de/wordpress" term="Hades" /><category scheme="http://www.olivergierke.de/wordpress" term="IT" /><category scheme="http://www.olivergierke.de/wordpress" term="aop" /><category scheme="http://www.olivergierke.de/wordpress" term="coding" /><category scheme="http://www.olivergierke.de/wordpress" term="hades" /><category scheme="http://www.olivergierke.de/wordpress" term="java" /><category scheme="http://www.olivergierke.de/wordpress" term="jpa" /><category scheme="http://www.olivergierke.de/wordpress" term="opensource" /><category scheme="http://www.olivergierke.de/wordpress" term="spring" />		<summary type="html"><![CDATA[In the last few days I have been working on a feature request of Hades that has been after me for quite a long time. Hades has always had built in support for auditing entities, which means it captured the current user of the application and set it as the creator or modifier on the [...]]]></summary>
		<content type="html" xml:base="http://www.olivergierke.de/wordpress/2010/06/hades-standing-on-the-shoulders-of-giants/">&lt;p&gt;In the last few days I have been working on a feature request of Hades that has been after me for quite a long time. Hades has always had built in support for auditing entities, which means it captured the current user of the application and set it as the creator or modifier on the entity whenever you called save on a Hades DAO. This is based on AOP, has always been a nice showcase of AOP applied, hopefully served a few users quite well. So far so good. Unfortunately the way it was implemented had two serious drawbacks:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It only works if you call &lt;code&gt;MyDao.save(…)&lt;/code&gt; explicitly&lt;/li&gt;
&lt;li&gt;It only works for the root entity you persist, not transitive ones.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These drawbacks have caused Will Jaynes to open up a &lt;a href="http://redmine.synyx.org/issues/53" title="Enable more than just root entity auditing"  target="_blank"&gt;ticket&lt;/a&gt; over a year ago already and I have been thinking about that issue from time to time, sometimes more deeply, sometimes just remembered it was still open. Finally I came up with a solution that not only fixes the two points mentioned above but also acts as a quite nice example of how powerful Spring as a toolbox can be, especially for framework or library developers. Here&amp;#8217;s the story…&lt;span id="more-500"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The right tool for the job&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Actually, implementing auditing with AOP was not the right choice in the first place. Well, it&amp;#8217;s not that AOP in general is the wrong hammer for this nail but rather how we applied it. Auditing based on a pointcut targeting a repository method is plain wrong if we deal with OR mappers, period. So I do not consider myself extraordinarily stupid so you and I might wonder what took me down that road.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Entity listeners&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The core abstraction for reacting on lifecycle events for entities in JPA are so called entity listeners. You can either annotate the entity itself with annotations like &lt;code&gt;@PrePersist&lt;/code&gt; or &lt;code&gt;@PreUpdate&lt;/code&gt; or use a dedicated class with annotated methods in case you want to implement common hooks you might want to apply to a common set of classes. You activate those entity listeners by either annotating the entity with &lt;code&gt;@EntityListeners&lt;/code&gt; or configure them in your &lt;code&gt;orm.xml&lt;/code&gt;. The reason they never seemed suitable for me is that they get instantiated by the JPA provider and thus &amp;#8211; by default &amp;#8211; lack any means of injecting dependencies into them (the &lt;code&gt;AuditorAware&lt;/code&gt; instance knowing who is the current user in our case).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;@Configurable&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Fortunately Spring offers injecting dependencies into classes created with &lt;code&gt;new&lt;/code&gt; by adding an &lt;code&gt;@Configurable&lt;/code&gt; to the class to be instantiated. You simply have to get a Spring aspect woven into that class then and activate in your apps XML config and Spring will intercept the instantiation of that class and either autowire dependencies or use a blueprint prototype bean to determine what has to be wired how. (For details see a &lt;a title="Using Spring's @Configurable in three easy steps" href="http://www.olivergierke.de/wordpress/2009/05/using-springs-configurable-in-three-easy-steps/" target="_blank"&gt;former blogpost&lt;/a&gt; or the &lt;a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/aop.html#aop-atconfigurable"&gt;reference documentation&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;So let&amp;#8217;s recap what we have here: I let the aspect be compiled into my &lt;code&gt;AuditingEntityListener&lt;/code&gt; and activate  as well as a prototype bean of the listener getting a &lt;code&gt;StubAuditorAware&lt;/code&gt; injected in my integration tests config file. Hm, doesn&amp;#8217;t work… What&amp;#8217;s wrong? Here&amp;#8217;s the critical part of the reference doc.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Instances of &lt;code&gt;@Configurable&lt;/code&gt; objects created before the aspect has been configured will result in a warning being issued to the log and no configuration of the object taking place. An example might be a bean in the Spring configuration that creates domain objects when it is initialized by Spring. In this case you can use the &lt;code&gt;depends-on&lt;/code&gt; bean attribute to manually specify that the bean depends on the configuration aspect.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Okay, it seems the aspect is not yet active when my &lt;code&gt;LocalContainerEntityManagerFactoryBean&lt;/code&gt; gets instantiated which in turn instantiates my entity listener. The docs recommend (no pun intended) to emphasize the order of the beans by adding a &lt;code&gt;depends-on&lt;/code&gt; attribute to the bean that manually instantiates objects (the &lt;code&gt;EntityManagerFactoryBean&lt;/code&gt; in our case). First: what bean to depend on since spring-configured has no id. Ah, it turns out Spring registers the aspect under &lt;code&gt;org.springframework.context.config.internalBeanConfigurerAspect&lt;/code&gt;. So I&amp;#8217;d essentially need something like this to make sure the &lt;code&gt;EntityManagerFactory&lt;/code&gt; already sees the DI aspect:&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;

&lt;context:spring-configured /&gt;

&lt;bean class="….LocalContainerEntitiyManagerFacotryBean"
  depends-on="org.springframework.context.config.internalBeanConfigurerAspect"/&gt;
&lt;/pre&gt;
&lt;p&gt;Well, wait… of course I could document that this was necessary but that would bloat Hades user&amp;#8217;s infrastructure configuration, expose Spring internal bean names and make things unnecessary complex.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Spring container hooks &amp;#8211; BeanFactoryPostProcessor&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Okay, so what we essentially need to do is transparently add a &lt;code&gt;depends-on="org.springframework.context.config.internalBeanConfigurerAspect"&lt;/code&gt; to the chosen &lt;code&gt;EntityManagerFactoryBean&lt;/code&gt; bean definition. Fortunately we can do this programatically by using one of the Spring container hooks, the &lt;code&gt;BeanFactoryPostProcessor&lt;/code&gt;. So I simply implemented a &lt;code&gt;AuditingBeanFactoryPostProcessor&lt;/code&gt; that transparently adds the (additional) &lt;code&gt;depends-on&lt;/code&gt; to bean definitions that create an &lt;code&gt;EntityManagerFactory&lt;/code&gt;. So the benefit here is that we can leave other user defined beans untouched. Let&amp;#8217;s take a look on what we have to configure on the Spring side to get things up and running:&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;
&lt;context:spring-configured /&gt;
&lt;bean class="….AuditingBeanFactoryPostProcessor" /&gt;

&lt;bean class="….auditing.support.AuditingEntityListener"&gt;
&lt;property value="auditorAware" ref="auditorAware" /&gt;
&lt;/bean&gt;

&lt;bean id="auditorAware" class="com.acme.MyAuditorAwareImpl" /&gt;
&lt;/pre&gt;
&lt;p&gt;As you can see, there&amp;#8217;s a lot of boilerplate XML config here. The only thing really custom is the delaration of the &lt;code&gt;MyAuditorAwareImpl&lt;/code&gt;. Now guess what? There&amp;#8217;s some Spring for that…  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Spring namespaces&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As you probably already know (as you might have used Hades already) Spring supports the implementation of custom XML namespaces since 2.5. We already implemented the &lt;code&gt;dao-config&lt;/code&gt; element in the Hades namespace so why not add one to activate auditing? So here&amp;#8217;s what we end up with:&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;&lt;hades:auditing auditor-aware-ref="auditorAware" /&gt;

&lt;bean id="auditorAware"
  class="com.acme.MyAuditorAwareImpl" /&gt;&lt;/pre&gt;
&lt;p&gt;Quite neat, isn&amp;#8217;t it? So let&amp;#8217;s summarize what we have gained from the plain auditing feature view:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;We get transparent auditing on all JPA managed entities, whether they are the root entity or a transitive one.&lt;/li&gt;
&lt;li&gt;No need to call &lt;code&gt;MyDao.save(…)&lt;/code&gt; to trigger auditing.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Nice, feature completed ;). Now let&amp;#8217;s take another step back an reflect what brought us there:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Spring&amp;#8217;s ability to inject dependencies into objects instantiated with &lt;code&gt;new&lt;/code&gt; through &lt;code&gt;@Configurable&lt;/code&gt; and AOP.&lt;/li&gt;
&lt;li&gt;Prevented custom configuration spread around into other beans thorugh Spring&amp;#8217;s &lt;code&gt;BeanFactoryPostProcessor&lt;/code&gt; container hook.&lt;/li&gt;
&lt;li&gt;Reduced the amount of configuration required through a custom namespace to hand an expressive concise configuration language (in our case in form of a single XML element ;) to the user instead of a generic verbose one.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Enough praising here, enjoy auditing with Hades! =)&lt;/p&gt;
&lt;p&gt;P.S.: In case you want to take a glance at the sources checkout the &lt;a href="http://redmine.synyx.org/projects/hades/repository/revisions/11827"&gt;commits&lt;/a&gt; I&amp;#8217;ve done for the &lt;a href="http://redmine.synyx.org/issues/53" title="Enable more than just root entity auditing"&gt;feature request&lt;/a&gt;.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/olivergierke/soulpower/~4/q680pum3Dyk" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://www.olivergierke.de/wordpress/2010/06/hades-standing-on-the-shoulders-of-giants/#comments" thr:count="3" />
		<link rel="replies" type="application/atom+xml" href="http://www.olivergierke.de/wordpress/2010/06/hades-standing-on-the-shoulders-of-giants/feed/atom/" thr:count="3" />
		<thr:total>3</thr:total>
	<feedburner:origLink>http://www.olivergierke.de/wordpress/2010/06/hades-standing-on-the-shoulders-of-giants/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Oliver Gierke</name>
						<uri>http://www.olivergierke.de</uri>
					</author>
		<title type="html"><![CDATA[Hades 2.0.0.RC2 introduces transactional DAOs]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/olivergierke/soulpower/~3/pQgDdWkjM7I/" />
		<id>http://www.olivergierke.de/wordpress/?p=495</id>
		<updated>2010-06-22T19:11:24Z</updated>
		<published>2010-06-22T19:11:24Z</published>
		<category scheme="http://www.olivergierke.de/wordpress" term="Hades" /><category scheme="http://www.olivergierke.de/wordpress" term="hades" /><category scheme="http://www.olivergierke.de/wordpress" term="opensource" /><category scheme="http://www.olivergierke.de/wordpress" term="releases" />		<summary type="html"><![CDATA[Our latest Hades release of the 2.0 branch is introducing transactionality of DAO instances as main new feature. Of course you can read up the reference documentation for some general guidelines but I want to use the chance to give a more detailed look into why we introduce this and how some details work.
These days, [...]]]></summary>
		<content type="html" xml:base="http://www.olivergierke.de/wordpress/2010/06/hades-2-0-0-rc2-introduces-transactional-daos/">&lt;p&gt;Our latest Hades &lt;a title="Hades release announcement" href="http://redmine.synyx.org/news/18" target="_blank"&gt;release&lt;/a&gt; of the 2.0 branch is introducing transactionality of DAO instances as main new feature. Of course you can read up the reference documentation for some general guidelines but I want to use the chance to give a more detailed look into why we introduce this and how some details work.&lt;span id="more-495"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;These days, some kind of back-to-the-basics approach regarding architecture layering is widely accepted as best practices. Thus you don&amp;#8217;t want to introduce a layer just because of some merely technical needs. A typical candidate layer for being obsolete is the service layer. Especially in web applications where you pretty much store entities that are equipped with rich behavior themselves the service layer is quite an artificial one that only demarcates transactions but then delegates to the underlying data access layer. Using Hades in such an application you had needed the additional transaction demarcation somewhere as it didn&amp;#8217;t deal with transactions itself out of the box. So the only option to get rid of a service layer was to use e.g. &lt;code&gt;@Transactional&lt;/code&gt; at a Spring MVC controller e.g. which is rather a sub-optimal solution.&lt;/p&gt;
&lt;p&gt;So actually we were quite reluctant to the idea of applying transactions to Hades DAO instances as there were some crucial points to consider:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Actually a DAO layer might not be at the right level of abstraction.&lt;/strong&gt; Usually you define transactions on a more business related method than a plain &lt;code&gt;save(…)&lt;/code&gt; or &lt;code&gt;findByUsername(…)&lt;/code&gt;. So if we enable transactions at DAO methods we have to make sure that they seamlessly can be expanded to more coarse grained methods and the DAOs take part in those transactions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If we apply transactions we don&amp;#8217;t want to imply our transaction model to the user&amp;#8217;s application.&lt;/strong&gt; As Spring provides various means to define transactions, we don&amp;#8217;t want to take that decision from the developer. So in case she wants to decide for a particular model, she has to be able to do so, no matter what we chose.&lt;/li&gt;
&lt;li&gt;Although the transactional behavior that we define for CRUD methods might be okay for 90% of the use cases &lt;strong&gt;there has to be a way to override the defaults and replace them by some custom one.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;As Spring 3.0 &lt;strong&gt;support&lt;/strong&gt;s&lt;strong&gt; multiple transaction managers&lt;/strong&gt; via &lt;code&gt;@Transactional&lt;/code&gt; we have to make sure we participate in the right transaction depending on in which context the DAO is used.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;It has to be easy to define transaction configuration for DAO interfaces&lt;/strong&gt; containing the finder methods.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We decided to use &lt;code&gt;@Transactional&lt;/code&gt; annotations at the &lt;code&gt;GenericJpaDao&lt;/code&gt; implementation class and activate annotation based transactions for the proxies explicitly through the &lt;code&gt;GenericDaoFactoryBean&lt;/code&gt;. This means that the CRUD operations of the DAO instances will be transactional if called standalone or participate in a transaction in case there&amp;#8217;s already one running for the current transaction manager (read up details on multiple transaction managers &lt;a title="Spring reference documentation on multiple="&gt;here&lt;/a&gt;). So it doesn&amp;#8217;t matter if you declare your transactional boundaries via &lt;code&gt;@Transactional&lt;/code&gt;, too, or use e.g. XML configuration or even &lt;code&gt;TransactionTemplate&lt;/code&gt;. This gets us solutions for issues 1 and 2.&lt;/p&gt;
&lt;p&gt;Issue 5 is quite easy to solve as you can simply annotate the finder methods of your DAO interface (or the interface itself) with &lt;code&gt;@Transactional&lt;/code&gt; and transactions get applied as you are used to with Spring.&lt;/p&gt;
&lt;p&gt;The actual tricky part is issue 3. The main idea here is to simply redeclare the CRUD method originally declared in &lt;code&gt;GenericDao&lt;/code&gt; inside your concrete DAO interface and reconfigure transactions as you like. So supposed you want to get rid of the readOnly flag at &lt;code&gt;readByPrimaryKey(…)&lt;/code&gt; set to true (as we chose to default the transaction configuration to, as this applies some performance optimizations on the persistence provider as well as the JDBC driver), you can do this as follows:&lt;/p&gt;
&lt;pre class="java" name="code"&gt;public interface UserDao extends GenericDao&amp;lt;User, Long&amp;gt; {

  @Override
  @Transactional
  User readByPrimaryKey(Long key);
}&lt;/pre&gt;
&lt;p&gt;Getting this to work needs some reflection magic as we of course still have to delegate the call to that method to the &lt;code&gt;GenericJpaDao&lt;/code&gt; instance but according to the Java Reflection API it of course does only implement &lt;code&gt;GenericDao.readByPrimaryKey(…)&lt;/code&gt; and not &lt;code&gt;UserDao.readByPrimaryKey(…)&lt;/code&gt;. Long story short, we can find out the method that has to be invoked so we can hand this reconfiguration model to the user and gain much flexibility on this side.&lt;/p&gt;
&lt;p&gt;Issue 4 is not that interesting as we simply have to configure our internal &lt;code&gt;TransactionInterceptor&lt;/code&gt; to lookup the appropriate &lt;code&gt;PlatformTransactionManager&lt;/code&gt; instance in a lazy-loading-like fashion but that all happens under the covers and you don&amp;#8217;t need to take care of this.&lt;/p&gt;
&lt;p&gt;So let me quickly summarize what 2.0.0.RC2 brings you in regard of transactions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Transactional CRUD methods (everything declared in &lt;code&gt;GenericDao&lt;/code&gt;) with appropriate defaults (&lt;code&gt;readOnly&lt;/code&gt; flag set to true on read-only methods) that automatically take part in more coarse grained transactions if necessary&lt;/li&gt;
&lt;li&gt;The ability to use &lt;code&gt;@Transactional&lt;/code&gt; for your concrete DAO interfaces&lt;/li&gt;
&lt;li&gt;The ability to reconfigure the transactional behavior of the CRUD methods by simply redeclaring a method inside the concrete DAO interface&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="http://feeds.feedburner.com/~r/olivergierke/soulpower/~4/pQgDdWkjM7I" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://www.olivergierke.de/wordpress/2010/06/hades-2-0-0-rc2-introduces-transactional-daos/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.olivergierke.de/wordpress/2010/06/hades-2-0-0-rc2-introduces-transactional-daos/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://www.olivergierke.de/wordpress/2010/06/hades-2-0-0-rc2-introduces-transactional-daos/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Oliver Gierke</name>
						<uri>http://www.olivergierke.de</uri>
					</author>
		<title type="html"><![CDATA[Changing a project&#8217;s artifact id in Sonar]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/olivergierke/soulpower/~3/qKvZKDQdxck/" />
		<id>http://www.olivergierke.de/wordpress/?p=490</id>
		<updated>2010-06-02T15:57:07Z</updated>
		<published>2010-06-02T15:56:48Z</published>
		<category scheme="http://www.olivergierke.de/wordpress" term="IT" /><category scheme="http://www.olivergierke.de/wordpress" term="howto" /><category scheme="http://www.olivergierke.de/wordpress" term="opensource" /><category scheme="http://www.olivergierke.de/wordpress" term="tools" /><category scheme="http://www.olivergierke.de/wordpress" term="workaround" />		<summary type="html"><![CDATA[Sonar is a great tool to take care of code quality in your software projects. I use it heavily to monitor the open source projects I am involved with. When working on getting Hades published into Maven central I had to polish it&#8217;s pom.xml and felt the need to align the parent project&#8217;s artifact to [...]]]></summary>
		<content type="html" xml:base="http://www.olivergierke.de/wordpress/2010/06/changing-a-projects-artifact-id-in-sonar/">&lt;p&gt;&lt;a title="Sonar" href="http://sonar.codehaus.org/" target="_blank"&gt;Sonar&lt;/a&gt; is a great tool to take care of code quality in your software projects. I use it heavily to monitor the &lt;a title="Sonar instance @ synyx.org" href="http://techqa.synyx.org" target="_blank"&gt;open source projects I am involved with&lt;/a&gt;. When working on getting &lt;a title="Hades project home" href="http://hades.synyx.org" target="_blank"&gt;Hades&lt;/a&gt; published into Maven central I had to polish it&amp;#8217;s &lt;code&gt;pom.xml&lt;/code&gt; and felt the need to align the parent project&amp;#8217;s artifact to our chosen OSGi compatible package notation for artifacts. So prior to releasing it to Maven central I changed the artifact id from &lt;code&gt;hades-parent&lt;/code&gt; to &lt;code&gt;org.synyx.hades.parent&lt;/code&gt;. Everything fine until I pushed the metrics of the 1.5.1 release into Sonar.&lt;/p&gt;
&lt;p&gt;Sonar created a new project, as it cannot know about my refactoring. So what to do? I spoke to &lt;a title="Simon Brandhof @ Twitter" href="http://twitter.com/SimonBrandhof" target="_blank"&gt;Simon Brandhof&lt;/a&gt; and apparently there&amp;#8217;s no feature in Sonar to change the artifact id via the user interface. So I opened a JIRA &lt;a title="JIRA issue for renaming projects" href="http://jira.codehaus.org/browse/SONAR-1608" target="_blank"&gt;issue&lt;/a&gt; for it, feel free to vote for it if you like. Meanwhile we could achieve this by manually altering the &lt;code&gt;kee&lt;/code&gt; column inside the &lt;code&gt;PROJECTS&lt;/code&gt; table. It contains entries of the form &lt;code&gt;${groupId}:${artifactId}(:${branchName})&lt;/code&gt; for entries of type &lt;code&gt;PRJ&lt;/code&gt; (i guess that stands for project. Altering these entries solved the problem.&lt;/p&gt;
&lt;p&gt;Thanks to Simon and Verschdl for help!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/olivergierke/soulpower/~4/qKvZKDQdxck" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://www.olivergierke.de/wordpress/2010/06/changing-a-projects-artifact-id-in-sonar/#comments" thr:count="1" />
		<link rel="replies" type="application/atom+xml" href="http://www.olivergierke.de/wordpress/2010/06/changing-a-projects-artifact-id-in-sonar/feed/atom/" thr:count="1" />
		<thr:total>1</thr:total>
	<feedburner:origLink>http://www.olivergierke.de/wordpress/2010/06/changing-a-projects-artifact-id-in-sonar/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Oliver Gierke</name>
						<uri>http://www.olivergierke.de</uri>
					</author>
		<title type="html"><![CDATA[Upgrade you Roo addons to 1.1.0]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/olivergierke/soulpower/~3/KfHzg7XGZO0/" />
		<id>http://www.olivergierke.de/wordpress/?p=476</id>
		<updated>2010-06-02T15:58:21Z</updated>
		<published>2010-06-01T07:52:30Z</published>
		<category scheme="http://www.olivergierke.de/wordpress" term="IT" /><category scheme="http://www.olivergierke.de/wordpress" term="howto" /><category scheme="http://www.olivergierke.de/wordpress" term="roo" /><category scheme="http://www.olivergierke.de/wordpress" term="spring" />		<summary type="html"><![CDATA[Spring Roo 1.1.0 will be based on OSGi and Apache Felix in particular as runtime platform. This of course will affect the already existing addons developed for Roo. The core ones are of course updated by the Spring Roo team but in case you have developed a custom one the steps needed to be taken [...]]]></summary>
		<content type="html" xml:base="http://www.olivergierke.de/wordpress/2010/06/upgrade-you-roo-addons-to-1-1-0/">&lt;p&gt;Spring Roo 1.1.0 will be based on OSGi and Apache Felix in particular as runtime platform. This of course will affect the already existing addons developed for Roo. The core ones are of course updated by the Spring Roo team but in case you have developed a custom one the steps needed to be taken are not really obvious. However, I took some time studying the core addons and here&amp;#8217;s a step by step guide that takes you from a 1.0.x addon to a 1.1.0 one:&lt;span id="more-476"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Make sure, your project version is a valid OSGi vesion&lt;/strong&gt;Default Maven version scheme is invalid for &lt;code&gt;SNAPSHOT&lt;/code&gt; versions as the 3rd part of the version has to be purely numeric in OSGi. In case you ignore this, you won&amp;#8217;t get the bundle deployed into the Roo OSGi runtime. So you have to stick to something like &lt;code&gt;0.1.0.BUILD-SNAPSHOT&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Change packaging of your project to bundle&lt;/strong&gt;As your plugin will result in an OSGi bundle you need to change the packaging from simple &lt;code&gt;jar&lt;/code&gt; to &lt;code&gt;bundle&lt;/code&gt;. This will cause the Maven bundle plugin creating the necessary metadata for you out of the box.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Change the type of the dependencies to bundle&lt;/strong&gt;Similar to the point above you need to reference dependencies as bundles. Again, to let the Maven bundle plugin do its job.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sync build section of your pom with the one provided in the addon template&lt;/strong&gt;We had to do some changes to them &lt;code&gt;pom.xml&lt;/code&gt; created for artifacts so you will need to catch up with them. This is mostly related to the Maven bundle plugin as well as the Maven SCR plugin (see next point for details).
&lt;pre class="bash"&gt;project --topLevelPackage com.mycompany.myproject.roo.addon \
  --template ROO_ADDON_SIMPLE&lt;/pre&gt;
&lt;p&gt;The easiest way to do so is simply creating a dummy addon project using the template and copy the plugin configuration into your pom.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Replace @ScopeDevelopment annotations with @Component and @Service&lt;/strong&gt;Roo uses Apache Felix as OSGi runtime and thus uses &lt;code&gt;@Component&lt;/code&gt; and &lt;code&gt;@Service&lt;/code&gt; annotations in combination with the Maven SCR plugin (for details see &lt;a title="Maven SCR plugin" href="http://felix.apache.org/site/apache-felix-maven-scr-plugin.html"&gt;Maven SCR plugin documentation&lt;/a&gt;) to create descriptors for the OSGi declarative services infrastructure.
&lt;pre class="java"&gt;@Service
@Component
public class MyCommands implements CommandMarker {

  @Reference MyOperations operations;

  // Your code goes here
}&lt;/pre&gt;
&lt;p&gt;So every &lt;code&gt;@ScopeDevelopment&lt;/code&gt; annotation you used at your command and operations classes has to be replaced by &lt;code&gt;@Service&lt;/code&gt; and &lt;code&gt;@Component&lt;/code&gt;. If you had injected other services into your command or operations class you can use &lt;code&gt;@Reference&lt;/code&gt; to wire that into your component instance. Note, that your class will have to implement at least one interface Felix can publish the component instance under. As there might be further tweaks necessary, have a closer look at the output the Maven SCR plugin generates. It will log errors in case you still need to change something.&lt;/li&gt;
&lt;/ol&gt;
&lt;img src="http://feeds.feedburner.com/~r/olivergierke/soulpower/~4/KfHzg7XGZO0" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://www.olivergierke.de/wordpress/2010/06/upgrade-you-roo-addons-to-1-1-0/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.olivergierke.de/wordpress/2010/06/upgrade-you-roo-addons-to-1-1-0/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://www.olivergierke.de/wordpress/2010/06/upgrade-you-roo-addons-to-1-1-0/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Oliver Gierke</name>
						<uri>http://www.olivergierke.de</uri>
					</author>
		<title type="html"><![CDATA[The unknown 2nd Spring triangle]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/olivergierke/soulpower/~3/ISz493B0izU/" />
		<id>http://www.olivergierke.de/wordpress/?p=469</id>
		<updated>2010-05-09T16:45:54Z</updated>
		<published>2010-05-09T16:45:54Z</published>
		<category scheme="http://www.olivergierke.de/wordpress" term="IT" /><category scheme="http://www.olivergierke.de/wordpress" term="aop" /><category scheme="http://www.olivergierke.de/wordpress" term="coding" /><category scheme="http://www.olivergierke.de/wordpress" term="java" /><category scheme="http://www.olivergierke.de/wordpress" term="migration" /><category scheme="http://www.olivergierke.de/wordpress" term="patterns" /><category scheme="http://www.olivergierke.de/wordpress" term="spring" />		<summary type="html"><![CDATA[When skimming through Spring presentations explaining the building blocks of the framework you&#8217;ll often find a so called Spring triangle consisting of the following 3 parts:

Dependency Injection
Aspect Oriented Programming
Portable Service Abstraction

These 3 principles surround a plain POJO programming model and enable Spring to achieve what it is famous for. Portable and maintainable Java software. Having [...]]]></summary>
		<content type="html" xml:base="http://www.olivergierke.de/wordpress/2010/05/the-unknown-2nd-spring-triangle/">&lt;p&gt;When skimming through Spring presentations explaining the building blocks of the framework you&amp;#8217;ll often find a so called Spring triangle consisting of the following 3 parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Dependency Injection&lt;/li&gt;
&lt;li&gt;Aspect Oriented Programming&lt;/li&gt;
&lt;li&gt;Portable Service Abstraction&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These 3 principles surround a plain POJO programming model and enable Spring to achieve what it is famous for. Portable and maintainable Java software. Having that said, there is another triangle in my opinion that is touches developers even more when working with Spring. This triangle captures the way Spring can be &lt;em&gt;configured&lt;/em&gt;, thus &lt;em&gt;used&lt;/em&gt; and &amp;#8211; to a larger extend &amp;#8211; introduced into a project. But first things first, here&amp;#8217;s what I am talking about.&lt;span id="more-469"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;XML configuration&lt;/li&gt;
&lt;li&gt;Annotation configuration&lt;/li&gt;
&lt;li&gt;Programmatic usage&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Especially choosing between the first two approaches to configuration are an often discussed topic. To be honest, I don&amp;#8217;t think a Spring project will fail because of this issue. There a few guidelines one can use to decide on that topic but I don&amp;#8217;t want to go into that in detail in this post. Let&amp;#8217;s take a look at the three styles of usage from a more general perspective and how they enable usage of Spring itself.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;XML configuration&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This way of using Spring is probably a well known way to users that have worked with Spring for a long period of time already. Admittedly, this approach has several downsides (e.g. verbosity of configuration) but also results in some kind of application blueprint you can gain information about how a module is structured at a quick glance.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Annotation configuration&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This style of configuration is gaining more and more of traction these days. Spring&amp;#8217;s support for annotations is set up broadly since 2.5. 3.0 extends that support furthermore by supporting standardized annotations for dependency injection like &lt;code&gt;@Inject&lt;/code&gt;. Besides that Spring comes up with an annotation configuration style called JavaConfig, where you write dedicated configuration classes and annotate &lt;em&gt;them&lt;/em&gt; to define configuration metadata. This solves the problem of configuration of 3rd party classes that you cannot annotate directly anymore (e.g. DataSources etc.) that plain annotation config does not offer a solution for.&lt;/p&gt;
&lt;p&gt;Both styles of configuration (XML and annotations) leverage the usage of Spring as framework, defining application and infrastructure components that are managed by Spring at runtime. Besides that there is a 3rd option that is often neglected but a helpful one in certain scenarios.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Programmatic usage of Spring&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As all Spring abstractions (transactions, persistence etc.) are programmatically usable, which means you can simply drop the appropriate JAR into your classpath and use the classes as is using Spring &lt;em&gt;as library&lt;/em&gt; instead of as framework then. As they are written to support dependency injection the usage of the huge simplyfication of JDBC e.g. can be used by instantiating JdbcTemplate, handing it a DataSource and off you go.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Why do I mention that&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First thing is, that contrary to popular believe using Spring does not mean huge XML config files or even starting with the introduction of Dependency Injection into your application. You can use declarative transactions by simply using the AOP and transaction API &lt;em&gt;programatically&lt;/em&gt; in your already existing factory classes e.g. You can simplify your existing JDBC code hugely by using &lt;code&gt;JdbcTemplate&lt;/code&gt; without bothering with AOP or Dependency Injection at all. Thus there are many possible ways to adopt Spring with your application, it is no &amp;#8220;one size has to fit all&amp;#8221; approach but rather &lt;em&gt;enables you as developer&lt;/em&gt; to make a decision that suits your problem at hand.&lt;/p&gt;
&lt;p&gt;There is no silver bullet, more power to the developer!&lt;/p&gt;
&lt;p&gt;Second, the 2nd triangle is the actual means to allow exactly what I just described above. It enables developers to use each part of the first triangle and makes Spring the Swiss knife of application frameworks. So why choosing an axe instead? ;)&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/olivergierke/soulpower/~4/ISz493B0izU" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://www.olivergierke.de/wordpress/2010/05/the-unknown-2nd-spring-triangle/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.olivergierke.de/wordpress/2010/05/the-unknown-2nd-spring-triangle/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://www.olivergierke.de/wordpress/2010/05/the-unknown-2nd-spring-triangle/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Oliver Gierke</name>
						<uri>http://www.olivergierke.de</uri>
					</author>
		<title type="html"><![CDATA[Hades 1.5 released]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/olivergierke/soulpower/~3/nn4lNFfh9IE/" />
		<id>http://www.olivergierke.de/wordpress/?p=459</id>
		<updated>2010-04-11T09:52:59Z</updated>
		<published>2010-04-11T09:23:15Z</published>
		<category scheme="http://www.olivergierke.de/wordpress" term="Hades" /><category scheme="http://www.olivergierke.de/wordpress" term="IT" /><category scheme="http://www.olivergierke.de/wordpress" term="coding" /><category scheme="http://www.olivergierke.de/wordpress" term="hades" /><category scheme="http://www.olivergierke.de/wordpress" term="java" /><category scheme="http://www.olivergierke.de/wordpress" term="jpa" /><category scheme="http://www.olivergierke.de/wordpress" term="opensource" /><category scheme="http://www.olivergierke.de/wordpress" term="releases" /><category scheme="http://www.olivergierke.de/wordpress" term="spring" />		<summary type="html"><![CDATA[As you probably already might have noticed, yesterday we released Hades 1.5. Alongside with that the firs 2.0 release candiate sees the light of the day, too. Let me just take some lines to elaborate on the specialty of this release.
Why 1.5?
The first question that might arise is why this release is 1.5 whereas it&#8217;s [...]]]></summary>
		<content type="html" xml:base="http://www.olivergierke.de/wordpress/2010/04/hades-1-5-released/">&lt;p&gt;As you probably already might have noticed, yesterday we released Hades 1.5. Alongside with that the firs 2.0 release candiate sees the light of the day, too. Let me just take some lines to elaborate on the specialty of this release.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Why 1.5?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The first question that might arise is why this release is 1.5 whereas it&amp;#8217;s predecessor was 1.1.2. Originally the release was planned as 1.2 but as it introduces some long-ranging features and changes we thought it might be worth indicating that in a larger step of version numbers. As 2.0 is already taken for our JPA 2 upgrade, 1.5 was the choice to go. So what do I mean with &amp;#8220;long-ranging&amp;#8221;?&lt;span id="more-459"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Since it&amp;#8217;s beginning Hades relied on two major interfaces: &lt;code&gt;GenericDao&lt;/code&gt; and &lt;code&gt;Persistable&lt;/code&gt; where as especially the latter raised some discussions &lt;a title="Why do we need to implement Persistable?" href="http://redmine.synyx.org/boards/2/topics/8" target="_self"&gt;here&lt;/a&gt; and there. Although it is not that of a big deal to implement a 3rd party interface with an entity class it was indeed a hurdle for adoption. So why was it introduced in the first place. &lt;code&gt;GenericDao&lt;/code&gt; had the aim to abstract between creation and updates of objects. Although there slight semantic differences this maps to the difference between using &lt;code&gt;EntityManager&lt;/code&gt; methods &lt;code&gt;persist(…)&lt;/code&gt; and&lt;code&gt; merge(…)&lt;/code&gt;. To know what to call when &lt;code&gt;save(…)&lt;/code&gt; is being called on &lt;code&gt;GenericDao&lt;/code&gt; we have to be able to differentiate between a new and an existing entity. As this algorithm might vary from entity to entity, we chose to leave the burdon to decide that to the entity developer by implementing the interface.&lt;/p&gt;
&lt;p&gt;Although implementing this interface should not be a big deal actually, we (and the developer community) were not really satisfied with that solutions as the technical infrastructure slightly leaks into the domain abstraction which is somewhat suboptimal kindly speaking. The good news is: as of Hades 1.5 there is no need to implement &lt;code&gt;Persistable&lt;/code&gt; anymore. The DAO implementation now uses a reflective approach to lookup the id property of the entity and inspects its value. If it is &lt;code&gt;null&lt;/code&gt;, the entity is regarded as new or as already existing otherwise. So that&amp;#8217;s the default. If you need to tweak the semantics of new, simply implement &lt;code&gt;Persistable&lt;/code&gt; as the algorithm will be simply calling &lt;code&gt;isNew()&lt;/code&gt; on you instance then. So in effect, the interface comes into play if explicitly needed and not in any other case.&lt;/p&gt;
&lt;p&gt;That&amp;#8217;s the big news. Behind that we have a few new features regarding the XML namespace to be used in Spring applications. In case you have multiple &lt;code&gt;EntityManagerFactory&lt;/code&gt; beans declared (e.g. in case you work with more than one JPA persistence unit), you can now point the &lt;code&gt;dao-config&lt;/code&gt; and &lt;code&gt;dao&lt;/code&gt; elements to a specific EMF bean by using &lt;code&gt;entity-manager-factory-ref&lt;/code&gt; attribute. Furthermore using &lt;code&gt;exclude-filter&lt;/code&gt; and &lt;code&gt;include-filter&lt;/code&gt; (probably known from Spring&amp;#8217;s context namespace) can be used to tune DAO auto configuration in a more fine grained way. Besides that we have done a general overhaul to the query creation subsystem and now also allow keywords like &lt;code&gt;Between&lt;/code&gt;, &lt;code&gt;LessThan&lt;/code&gt; and &lt;code&gt;GreaterThan&lt;/code&gt; in method names. To round things up we&amp;#8217;ve fixed a few minor bugs here and there. For more details read the &lt;a title="Changelog" href="http://redmine.synyx.org/versions/show/34" target="_blank"&gt;changelog&lt;/a&gt; or the updated &lt;a title="Reference documentation" href="http://redmine.synyx.org/attachments/download/96" target="_blank"&gt;reference documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Hades 2.0&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Alongside this important step we make another one. JPA 2.0 specification was released a while ago and most existing JPA 1 application wil definately benefit from an upgrade as the new spec version really fills gaps the old one left to workaround for the developers. So what is our approach to the new spec. From a Hades point of view the most intresting part of the new spec is the criteria API as user&amp;#8217;s probably will base their custom DAO implementations on it. Furthermore upgrading (Spring) applications demands applications to upgrade to Spring 3.0 and a new major version of the persistence provider of choice we choose to dedicate a 2.0 version of Hades to it.&lt;/p&gt;
&lt;p&gt;So the first release candidate builds on top of Spring 3.0.2 as well as Hibernate 3.5, EclipseLink 2.0 as well as OpenJPA 2.0 Beta 3. We will probably wait for our final release until OpenJPA is final, too, but as the majority of users are split between Hibernate and EclipseLink we think that rolling out a release candidate is a good way to get feedback and battle proof the new version. The major change inside Hades 2.0 is that we dropped support of the read-by-example way to access entities. This had to be implemented in a provider specific way so that we could even simplify the codebase in that regard. Furthermore the DAO abstraction is now clearly centered around &lt;code&gt;GenericDao&lt;/code&gt; and not blurred with additional interfaces.&lt;/p&gt;
&lt;p&gt;So if you can upgrade to Spring 3.0.x and the JPA 2 ready persistence provider already, give Hades 2.0 a try. It should be a drop in replacement in this case. Having that said, it&amp;#8217;s probably worth mentioning that even Hades 1.5 can be used with JPA 2.0 but requires more extensive pom configuration on the developer side (as Spring 2.5.6 does not support JPA 2). As you&amp;#8217;d end up with a dependency setup similar to the one decalred in 2.0 you&amp;#8217;re probably better of just upgrading to Hades 2.0.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/olivergierke/soulpower/~4/nn4lNFfh9IE" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://www.olivergierke.de/wordpress/2010/04/hades-1-5-released/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.olivergierke.de/wordpress/2010/04/hades-1-5-released/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://www.olivergierke.de/wordpress/2010/04/hades-1-5-released/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Oliver Gierke</name>
						<uri>http://www.olivergierke.de</uri>
					</author>
		<title type="html"><![CDATA[Neglected classes in Spring &#8211; Part III]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/olivergierke/soulpower/~3/OkOxbazV00o/" />
		<id>http://www.olivergierke.de/wordpress/?p=453</id>
		<updated>2010-07-01T19:10:27Z</updated>
		<published>2010-04-07T15:49:31Z</published>
		<category scheme="http://www.olivergierke.de/wordpress" term="IT" /><category scheme="http://www.olivergierke.de/wordpress" term="coding" /><category scheme="http://www.olivergierke.de/wordpress" term="java" /><category scheme="http://www.olivergierke.de/wordpress" term="patterns" /><category scheme="http://www.olivergierke.de/wordpress" term="spring" />		<summary type="html"><![CDATA[Java web application developers often face the need to inject a regular Spring bean into a non-Spring-managed artifact like a Servlet or a JSP tag.. If you browse the web for you find various quite outdated solutions to it. No offense, by the time being these were quite appropriate solutions. One of them you&#8217;ll probably [...]]]></summary>
		<content type="html" xml:base="http://www.olivergierke.de/wordpress/2010/04/neglected-classes-in-spring-part-iii/">&lt;p&gt;Java web application developers often face the need to inject a regular Spring bean into a non-Spring-managed artifact like a Servlet or a JSP tag.. If you &lt;a title="Google: spring bean inject servlet" href="http://www.google.de/search?q=spring inject bean servlet"&gt;browse the web&lt;/a&gt; for you find various quite &lt;a href="http://andykayley.blogspot.com/2008/06/how-to-inject-spring-beans-into.html" target="_blank"&gt;outdated&lt;/a&gt; solutions to it. No offense, by the time being these were quite appropriate solutions. One of them you&amp;#8217;ll probably will find is the following:&lt;/p&gt;
&lt;pre class="java" name="code"&gt;public class MyServlet extends HttpServlet {

  private MyService service;

  @Override
  public void init(ServletConfig config) {

    ServletContext context =
      config.getServletContext();

    ApplicationContext ctx =
      WebApplicationContextUtils.
        getRequiredWebApplicationContext(context);

    service = ctx.getBean(MyService.class);
  }
}&lt;/pre&gt;
&lt;p&gt;Let&amp;#8217;s recap what we just have done. First we need to get access to the &lt;code&gt;ServletContext&lt;/code&gt; of the web application. A Spring &lt;code&gt;WebApplicationContext&lt;/code&gt; that was registered by a &lt;code&gt;ContextLoaderListener&lt;/code&gt; will be registered in the &lt;code&gt;ServletContext&lt;/code&gt; under a special name the framework knows, so that &lt;code&gt;WebApplicationContextUtils&lt;/code&gt; can then look it up and hand it out to you to manually retrieve Spring beans from it.&lt;/p&gt;
&lt;p&gt;Okay, that get&amp;#8217;s the job done. But we can reduce the effort and go a much nicer way, that reduces the amount of boilerplate even more. Spring 2.5.1 introduced a tiny helperclass &lt;code&gt;SpringBeanAutowiringSupport&lt;/code&gt; which is residing in &lt;code&gt;org.springframework.web.context.support&lt;/code&gt; spending a rather unregarded life. It offers a method &lt;code&gt;processInjectionBasedOnCurrentContext(Object target)&lt;/code&gt; that automatically injects Spring beans to properties of the given target using the usual annotation driven suspects (&lt;code&gt;@Autowired&lt;/code&gt;, &lt;code&gt;@Inject&lt;/code&gt;). So our sample code turns into something like this:&lt;/p&gt;
&lt;pre class="java" name="code"&gt;public class MyServlet extends HttpServlet {

  @Inject
  private MyService service;

  @Override
  public void init() {
    SpringBeanAutowiringSupport.
      processInjectionBasedOnCurrentContext(this);
  }
}&lt;/pre&gt;
&lt;p&gt;Done. Note, that we override the &lt;code&gt;init&lt;/code&gt; method without the &lt;code&gt;ServletConfig&lt;/code&gt; parameter as the called method looks up the actual &lt;code&gt;ApplicationContext&lt;/code&gt; from a static map held in &lt;code&gt;ContextLoader&lt;/code&gt; which  inherits from. If you need to lookup beans from an &lt;code&gt;ApplicationContext&lt;/code&gt; tied to a particular &lt;code&gt;ServletContext&lt;/code&gt; you can use &lt;code&gt;processInjectionBasedOnServletContext(Object target, ServletContext servletContext)&lt;/code&gt; and hand it the appropriate instances.&lt;/p&gt;
&lt;p&gt;P.S.: Thanks to &lt;a title="Eberhard Wolff's blog" href="http://jandiandme.blogspot.com/" target="_blank"&gt;Eberhard Wolff&lt;/a&gt; for pointing me at this.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/olivergierke/soulpower/~4/OkOxbazV00o" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://www.olivergierke.de/wordpress/2010/04/neglected-classes-in-spring-part-iii/#comments" thr:count="7" />
		<link rel="replies" type="application/atom+xml" href="http://www.olivergierke.de/wordpress/2010/04/neglected-classes-in-spring-part-iii/feed/atom/" thr:count="7" />
		<thr:total>7</thr:total>
	<feedburner:origLink>http://www.olivergierke.de/wordpress/2010/04/neglected-classes-in-spring-part-iii/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Oliver Gierke</name>
						<uri>http://www.olivergierke.de</uri>
					</author>
		<title type="html"><![CDATA[REST based web applications with Spring 3]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/olivergierke/soulpower/~3/Ch7JbIKP_7c/" />
		<id>http://www.olivergierke.de/wordpress/?p=450</id>
		<updated>2010-04-01T08:28:28Z</updated>
		<published>2010-04-01T08:26:16Z</published>
		<category scheme="http://www.olivergierke.de/wordpress" term="IT" /><category scheme="http://www.olivergierke.de/wordpress" term="rest" /><category scheme="http://www.olivergierke.de/wordpress" term="spring" /><category scheme="http://www.olivergierke.de/wordpress" term="talks" /><category scheme="http://www.olivergierke.de/wordpress" term="web" />		<summary type="html"><![CDATA[Yesterday I gave a talk on REST based web applications with Spring 3. You can download the slides or just watch &#8216;em below. You can also grab the sample code at github.
REST based web applications with Spring 3
View more presentations from Oliver Gierke.

]]></summary>
		<content type="html" xml:base="http://www.olivergierke.de/wordpress/2010/04/rest-based-web-applications-with-spring-3/">&lt;p&gt;Yesterday I gave a talk on REST based web applications with Spring 3. You can &lt;a title="Slides to download" href="http://www.olivergierke.de/wordpress/wp-content/uploads/2009/01/REST.pdf" target="_blank"&gt;download&lt;/a&gt; the slides or just watch &amp;#8216;em below. You can also grab the sample code at &lt;a title="Sample code @ github" href="http://github.com/olivergierke/spring-rest" target="_self"&gt;github&lt;/a&gt;.&lt;/p&gt;
&lt;div id="__ss_3610375" style="width: 425px;"&gt;&lt;strong style="display: block; margin: 12px 0 4px;"&gt;&lt;a title="REST based web applications with Spring 3" href="http://www.slideshare.net/olivergierke/rest-based-web-applications-with-spring-3"&gt;REST based web applications with Spring 3&lt;/a&gt;&lt;/strong&gt;&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;param name="allowScriptAccess" value="always" /&gt;&lt;param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=rest-100401031126-phpapp02&amp;amp;rel=0&amp;amp;stripped_title=rest-based-web-applications-with-spring-3" /&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;embed type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=rest-100401031126-phpapp02&amp;amp;rel=0&amp;amp;stripped_title=rest-based-web-applications-with-spring-3" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;
&lt;div style="padding: 5px 0 12px;"&gt;View more &lt;a href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a href="http://www.slideshare.net/olivergierke"&gt;Oliver Gierke&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/olivergierke/soulpower/~4/Ch7JbIKP_7c" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://www.olivergierke.de/wordpress/2010/04/rest-based-web-applications-with-spring-3/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.olivergierke.de/wordpress/2010/04/rest-based-web-applications-with-spring-3/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://www.olivergierke.de/wordpress/2010/04/rest-based-web-applications-with-spring-3/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Oliver Gierke</name>
						<uri>http://www.olivergierke.de</uri>
					</author>
		<title type="html"><![CDATA[New challenges]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/olivergierke/soulpower/~3/DKa0aXdh1Lk/" />
		<id>http://www.olivergierke.de/wordpress/?p=436</id>
		<updated>2010-02-10T08:53:54Z</updated>
		<published>2010-02-10T07:43:03Z</published>
		<category scheme="http://www.olivergierke.de/wordpress" term="Allgemein" /><category scheme="http://www.olivergierke.de/wordpress" term="hades" /><category scheme="http://www.olivergierke.de/wordpress" term="opensource" /><category scheme="http://www.olivergierke.de/wordpress" term="spring" /><category scheme="http://www.olivergierke.de/wordpress" term="synyx" />		<summary type="html"><![CDATA[It&#8217;s been official for a few days now, so I thought I could drop a public note about me joining SpringSource Germany (division of VMware) as Senior Consultant beginning March 1st this year. Time to look back on three exciting years at Synyx and an outlook of what&#8217;s about to come.
I joined Synyx almost exactly [...]]]></summary>
		<content type="html" xml:base="http://www.olivergierke.de/wordpress/2010/02/new-challenges/">&lt;p&gt;It&amp;#8217;s been official for a few days now, so I thought I could drop a public note about me joining &lt;a title="SpringSource Germany" href="http://www.springsource.de/" target="_blank"&gt;SpringSource Germany (division of VMware)&lt;/a&gt; as Senior Consultant beginning March 1st this year. Time to look back on three exciting years at &lt;a title="Synyx Homepage" href="http://www.synyx.de" target="_blank"&gt;Synyx&lt;/a&gt; and an outlook of what&amp;#8217;s about to come.&lt;/p&gt;
&lt;p&gt;I joined Synyx almost exactly 3 years ago. Since then I had an exciting time with awesome folks, a wide variety of customers, projects and conferences. As I dealt with enterprise Java software a ton, of course Spring has been a &lt;a title="Blog posts on Spring" href="http://www.olivergierke.de/wordpress/tag/spring" target="_blank"&gt;crucial part&lt;/a&gt; of my daily job, no matter if it was the core framework, the software eco system and people around it or the open source project &lt;a title="Hades project site" href="http://hades.synyx.org" target="_blank"&gt;Hades&lt;/a&gt; that I lead, which is based on Spring and carries Spring principles and values to the domain of easing data access with JPA.&lt;/p&gt;
&lt;p&gt;Besides that, the crucial part to me is that Spring and SpringSource as a company have always provided pragmatic solutions to real world problems that are of quality far beyond average. As I already became more and more involved with the Spring codebase, too, I am thrilled to join the team to even more close to the heart of the &amp;#8211; to me &amp;#8211; core principle of software engineering: &lt;em&gt;pragmatic, high quality solutions to real world problems&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;To wrap things up, I&amp;#8217;d like to say thank you to all the fellow developers, customers and people in general I met during my time at Synyx. If you need custom first class Java based business software, like to work with people that don&amp;#8217;t hesitate to think out of the box &amp;#8211; Synyx is the shop you&amp;#8217;re looking for.&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s been a pleasure! And it will be&amp;#8230;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/olivergierke/soulpower/~4/DKa0aXdh1Lk" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://www.olivergierke.de/wordpress/2010/02/new-challenges/#comments" thr:count="5" />
		<link rel="replies" type="application/atom+xml" href="http://www.olivergierke.de/wordpress/2010/02/new-challenges/feed/atom/" thr:count="5" />
		<thr:total>5</thr:total>
	<feedburner:origLink>http://www.olivergierke.de/wordpress/2010/02/new-challenges/</feedburner:origLink></entry>
	</feed>
