<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: AOP &#8211; Spring &#8211; Hibernate Sessions for background threads / jobs</title>
	<atom:link href="http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/feed/" rel="self" type="application/rss+xml" />
	<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/</link>
	<description>About software dev and more</description>
	<lastBuildDate>Fri, 27 Apr 2012 10:07:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Alberto</title>
		<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/comment-page-1/#comment-507</link>
		<dc:creator>Alberto</dc:creator>
		<pubDate>Sat, 19 May 2012 00:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://raulraja.com/?p=160#comment-507</guid>
		<description>Thanks a lot!</description>
		<content:encoded><![CDATA[<p>Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raul Raja</title>
		<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/comment-page-1/#comment-506</link>
		<dc:creator>Raul Raja</dc:creator>
		<pubDate>Sat, 19 May 2012 20:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://raulraja.com/?p=160#comment-506</guid>
		<description>@Alberto, AFAIK the TransactionInterceptor is used to declaratively configure pointcuts that will be surrounded by a transaction. For example methods of a given service. As far as the HibernateInterceptor in this post is mostly to open and close the session automatically in background threads. You should be able to use the TransactionInterceptor to provide a transaction when you think is necessary or @Transactional if you&#039;d rather configure it with annotations.</description>
		<content:encoded><![CDATA[<p>@Alberto, AFAIK the TransactionInterceptor is used to declaratively configure pointcuts that will be surrounded by a transaction. For example methods of a given service. As far as the HibernateInterceptor in this post is mostly to open and close the session automatically in background threads. You should be able to use the TransactionInterceptor to provide a transaction when you think is necessary or @Transactional if you&#8217;d rather configure it with annotations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alberto</title>
		<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/comment-page-1/#comment-505</link>
		<dc:creator>Alberto</dc:creator>
		<pubDate>Sat, 19 May 2012 02:20:00 +0000</pubDate>
		<guid isPermaLink="false">http://raulraja.com/?p=160#comment-505</guid>
		<description>Do you know the difference between HibernateInterceptor and TransactionInterceptor? I am trying to take over some code that is using TransactionInterceptor with the same purpose.</description>
		<content:encoded><![CDATA[<p>Do you know the difference between HibernateInterceptor and TransactionInterceptor? I am trying to take over some code that is using TransactionInterceptor with the same purpose.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raul Raja</title>
		<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/comment-page-1/#comment-503</link>
		<dc:creator>Raul Raja</dc:creator>
		<pubDate>Sat, 19 May 2012 08:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://raulraja.com/?p=160#comment-503</guid>
		<description>Nicolás, la parte importante del tutorial es que el contenedor de Spring es capaz de crear un proxy para tus servicios el cual abre y cierra el contexto de persistencia alreadedor de invocaciones en los metodos. En tu caso puedes obetner un proxy de &quot;RequestJob&quot; programaticamente de forma que la invocación del metodo a tu elección ya estaría dentro de las sessión de hibernate por ejemplo:

&lt;bean id=&quot;testBackgroundJobProxy&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot;&gt;
        &lt;property name=&quot;target&quot;&gt;
            &lt;ref bean=&quot;referenciaATuJobRequestQueImplementaRunnable&quot;/&gt;
        &lt;/property&gt;
        &lt;property name=&quot;proxyInterfaces&quot;&gt;
            &lt;value&gt;java.lang.Runnable&lt;/value&gt;
        &lt;/property&gt;
        &lt;property name=&quot;interceptorNames&quot;&gt;
            &lt;value&gt;hibernateInterceptor&lt;/value&gt;
        &lt;/property&gt;
    &lt;/bean&gt;

y lo obtienes:

applicationContext.getBean(&quot;testBackgroundJobProxy&quot;);

Buena suerte y ya me cuentas</description>
		<content:encoded><![CDATA[<p>Nicolás, la parte importante del tutorial es que el contenedor de Spring es capaz de crear un proxy para tus servicios el cual abre y cierra el contexto de persistencia alreadedor de invocaciones en los metodos. En tu caso puedes obetner un proxy de &#8220;RequestJob&#8221; programaticamente de forma que la invocación del metodo a tu elección ya estaría dentro de las sessión de hibernate por ejemplo:</p>
<p>&lt;bean id=&quot;testBackgroundJobProxy&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot;&gt;<br />
        &lt;property name=&quot;target&quot;&gt;<br />
            &lt;ref bean=&quot;referenciaATuJobRequestQueImplementaRunnable&quot;/&gt;<br />
        &lt;/property&gt;<br />
        &lt;property name=&quot;proxyInterfaces&quot;&gt;<br />
            &lt;value&gt;java.lang.Runnable&lt;/value&gt;<br />
        &lt;/property&gt;<br />
        &lt;property name=&quot;interceptorNames&quot;&gt;<br />
            &lt;value&gt;hibernateInterceptor&lt;/value&gt;<br />
        &lt;/property&gt;<br />
    &lt;/bean&gt;</p>
<p>y lo obtienes:</p>
<p>applicationContext.getBean(&#8220;testBackgroundJobProxy&#8221;);</p>
<p>Buena suerte y ya me cuentas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolás</title>
		<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/comment-page-1/#comment-502</link>
		<dc:creator>Nicolás</dc:creator>
		<pubDate>Sat, 19 May 2012 08:19:00 +0000</pubDate>
		<guid isPermaLink="false">http://raulraja.com/?p=160#comment-502</guid>
		<description>Hola Raúl,

En mi caso estoy tratando de utilizar un pool de hilos para ejecutar tareas. java.util.concurrent). En mi caso quiero que se vayan resolviendo a medida que van llegando las tareas, no cada cierto período de tiempo.

Como puedo proveer mis workers su correspondiente sesión de Hibernate?

un pseudo-código de lo que quiero hacer sería el siguiente:

ExecutorService servicePool = Executors.newFixedThreadPool(10);

public void processJob(CustomJob job) {
...
servicePool.execute(new RequestJob(job.getId());
...
}

donde Request implementa la interfaz Runnable.

Desde ya, muchas gracias!
saludos</description>
		<content:encoded><![CDATA[<p>Hola Raúl,</p>
<p>En mi caso estoy tratando de utilizar un pool de hilos para ejecutar tareas. java.util.concurrent). En mi caso quiero que se vayan resolviendo a medida que van llegando las tareas, no cada cierto período de tiempo.</p>
<p>Como puedo proveer mis workers su correspondiente sesión de Hibernate?</p>
<p>un pseudo-código de lo que quiero hacer sería el siguiente:</p>
<p>ExecutorService servicePool = Executors.newFixedThreadPool(10);</p>
<p>public void processJob(CustomJob job) {<br />
&#8230;<br />
servicePool.execute(new RequestJob(job.getId());<br />
&#8230;<br />
}</p>
<p>donde Request implementa la interfaz Runnable.</p>
<p>Desde ya, muchas gracias!<br />
saludos</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raul Raja</title>
		<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/comment-page-1/#comment-495</link>
		<dc:creator>Raul Raja</dc:creator>
		<pubDate>Sat, 19 May 2012 10:18:00 +0000</pubDate>
		<guid isPermaLink="false">http://raulraja.com/?p=160#comment-495</guid>
		<description>Lucas aslo if you&#039;re using JPA you should be able to just inject the persistence context with:

@PersistenceContext
private EntityManager entityManager;

...

entityManager.createQuery(...).setParameter(&quot;...&quot;, ...).getResultList();</description>
		<content:encoded><![CDATA[<p>Lucas aslo if you&#8217;re using JPA you should be able to just inject the persistence context with:</p>
<p>@PersistenceContext<br />
private EntityManager entityManager;</p>
<p>&#8230;</p>
<p>entityManager.createQuery(&#8230;).setParameter(&#8220;&#8230;&#8221;, &#8230;).getResultList();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raul Raja</title>
		<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/comment-page-1/#comment-494</link>
		<dc:creator>Raul Raja</dc:creator>
		<pubDate>Sat, 19 May 2012 10:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://raulraja.com/?p=160#comment-494</guid>
		<description>Lucas, glad you found the answer and you found the post useful!</description>
		<content:encoded><![CDATA[<p>Lucas, glad you found the answer and you found the post useful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucas</title>
		<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/comment-page-1/#comment-493</link>
		<dc:creator>Lucas</dc:creator>
		<pubDate>Sat, 19 May 2012 07:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://raulraja.com/?p=160#comment-493</guid>
		<description>Hi Raul,
I found the answer to my own question, I should use autowiring which is what I was using before in my app:
@Autowired
private ObjectService object_service;
public void run() {
		List objects = object_service.findAllObject();
	}

Thank you for this useful post, seriously, I spent a lot of time trying to figure this out.
I&#039;m sorry for clustering your page with questions.
Thanks once more,
Lucas</description>
		<content:encoded><![CDATA[<p>Hi Raul,<br />
I found the answer to my own question, I should use autowiring which is what I was using before in my app:<br />
@Autowired<br />
private ObjectService object_service;<br />
public void run() {<br />
		List objects = object_service.findAllObject();<br />
	}</p>
<p>Thank you for this useful post, seriously, I spent a lot of time trying to figure this out.<br />
I&#8217;m sorry for clustering your page with questions.<br />
Thanks once more,<br />
Lucas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucas</title>
		<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/comment-page-1/#comment-492</link>
		<dc:creator>Lucas</dc:creator>
		<pubDate>Sat, 19 May 2012 05:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://raulraja.com/?p=160#comment-492</guid>
		<description>I am aware you posted this last year and I&#039;m not as proficient with persistence as I would like to be.
On question I have is:
If you want to retrieve all the the rows from table A. How would you do that in TestBackgroundJobImpl.run()?

I really don&#039;t know which way to go to get the session and to create a Criteria object.
Thanks in advance,
Lucas</description>
		<content:encoded><![CDATA[<p>I am aware you posted this last year and I&#8217;m not as proficient with persistence as I would like to be.<br />
On question I have is:<br />
If you want to retrieve all the the rows from table A. How would you do that in TestBackgroundJobImpl.run()?</p>
<p>I really don&#8217;t know which way to go to get the session and to create a Criteria object.<br />
Thanks in advance,<br />
Lucas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francesco Chicchiricco</title>
		<link>http://raulraja.com/2009/06/13/aop-spring-hibernate-sessions-for-background-threads-jobs/comment-page-1/#comment-489</link>
		<dc:creator>Francesco Chicchiricco</dc:creator>
		<pubDate>Sat, 19 May 2012 07:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://raulraja.com/?p=160#comment-489</guid>
		<description>Thanks for your post!

I&#039;ve updated your source code to work with JPA 2.0: read at http://chicchiricco.blogspot.com/2011/07/aop-spring-jpa-for-background-threads.html.</description>
		<content:encoded><![CDATA[<p>Thanks for your post!</p>
<p>I&#8217;ve updated your source code to work with JPA 2.0: read at <a href="http://chicchiricco.blogspot.com/2011/07/aop-spring-jpa-for-background-threads.html" rel="nofollow">http://chicchiricco.blogspot.com/2011/07/aop-spring-jpa-for-background-threads.html</a>.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

