<?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: Using JPA in Spring without referencing Spring</title>
	<atom:link href="http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/</link>
	<description>The voice of SpringSource</description>
	<pubDate>Sun, 14 Mar 2010 23:12:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Erik</title>
		<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/comment-page-1/#comment-167905</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Sun, 09 Aug 2009 11:43:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2006/08/07/using-jpa-in-spring-without-referencing-spring/#comment-167905</guid>
		<description>If you're getting null pointer exceptions and your setEntityManager() method isn't being called by Spring (causing your entity manager to not be injected), consider putting the @PersistenceContext annotation on the field instead of the setter.</description>
		<content:encoded><![CDATA[<p>If you&#039;re getting null pointer exceptions and your setEntityManager() method isn&#039;t being called by Spring (causing your entity manager to not be injected), consider putting the @PersistenceContext annotation on the field instead of the setter.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William</title>
		<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/comment-page-1/#comment-167875</link>
		<dc:creator>William</dc:creator>
		<pubDate>Sat, 08 Aug 2009 07:29:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2006/08/07/using-jpa-in-spring-without-referencing-spring/#comment-167875</guid>
		<description>Thank you for the example, but I have a small question. If we wanted to have an entity manager of 'extended' context, how do we go about it given the example? My issue is that I need to implements a 'long conversation' (I could not solve this in spring alone) - as EJB supports it with a session bean, as long as the entity manager survives over many thread calls. In that case, is this example still 'conversation' safe, if you know what I mean?

Will</description>
		<content:encoded><![CDATA[<p>Thank you for the example, but I have a small question. If we wanted to have an entity manager of &#039;extended&#039; context, how do we go about it given the example? My issue is that I need to implements a &#039;long conversation&#039; (I could not solve this in spring alone) - as EJB supports it with a session bean, as long as the entity manager survives over many thread calls. In that case, is this example still &#039;conversation&#039; safe, if you know what I mean?</p>
<p>Will</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shashi</title>
		<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/comment-page-1/#comment-165669</link>
		<dc:creator>Shashi</dc:creator>
		<pubDate>Fri, 08 May 2009 08:33:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2006/08/07/using-jpa-in-spring-without-referencing-spring/#comment-165669</guid>
		<description>Hi,

Finally I could solve all the issues. The issue about the null entitymanager was resolved when I replaced

HTML Code:

&lt;bean		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /&gt;

with

&lt;context:annotation-config/&gt;


Regards,
Shashi</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Finally I could solve all the issues. The issue about the null entitymanager was resolved when I replaced</p>
<p>HTML Code:</p>
<p>&lt;bean		class=&#034;org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor&#034; /&gt;</p>
<p>with</p>
<p>&lt;context:annotation-config/&gt;</p>
<p>Regards,<br />
Shashi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shashi</title>
		<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/comment-page-1/#comment-165668</link>
		<dc:creator>Shashi</dc:creator>
		<pubDate>Fri, 08 May 2009 08:31:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2006/08/07/using-jpa-in-spring-without-referencing-spring/#comment-165668</guid>
		<description>Hi,

Finally I could solve all the issues. The issue about the null entitymanager was resolved when I replaced



with



Regards,
Shashi</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Finally I could solve all the issues. The issue about the null entitymanager was resolved when I replaced</p>
<p>with</p>
<p>Regards,<br />
Shashi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shashi</title>
		<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/comment-page-1/#comment-165664</link>
		<dc:creator>Shashi</dc:creator>
		<pubDate>Fri, 08 May 2009 07:01:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2006/08/07/using-jpa-in-spring-without-referencing-spring/#comment-165664</guid>
		<description>Hi,

Thanks for your post. It was of great help for setting up the project with eclipselink. 
Our project worked all fine in non-dm environment. 

However currently we have a requirement to port our project to OSGI. As a first step I am trying to use Spring-DM for making the service layer work. I faced many other problems I posted at http://forum.springsource.org/showthread.php?t=71414. I am using the loadtimeweaver provided by Martin in his blog http://martinlippert.blogspot.com/2009/04/load-time-weaving-for-spring-dm.html. 

Now when I run the project in OSGI environment I see that entitymanager is not getting injected in the service. Hence I get NPE.
Does anybody have any inputs?

Thanks in advance,
Shashi</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for your post. It was of great help for setting up the project with eclipselink.<br />
Our project worked all fine in non-dm environment. </p>
<p>However currently we have a requirement to port our project to OSGI. As a first step I am trying to use Spring-DM for making the service layer work. I faced many other problems I posted at <a href="http://forum.springsource.org/showthread.php?t=71414" rel="nofollow">http://forum.springsource.org/showthread.php?t=71414</a>. I am using the loadtimeweaver provided by Martin in his blog <a href="http://martinlippert.blogspot.com/2009/04/load-time-weaving-for-spring-dm.html" rel="nofollow">http://martinlippert.blogspot.com/2009/04/load-time-weaving-for-spring-dm.html</a>. </p>
<p>Now when I run the project in OSGI environment I see that entitymanager is not getting injected in the service. Hence I get NPE.<br />
Does anybody have any inputs?</p>
<p>Thanks in advance,<br />
Shashi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Lim</title>
		<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/comment-page-1/#comment-148266</link>
		<dc:creator>Adrian Lim</dc:creator>
		<pubDate>Thu, 05 Mar 2009 03:15:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2006/08/07/using-jpa-in-spring-without-referencing-spring/#comment-148266</guid>
		<description>Hi all, I am currently using Spring JPA to inject my Entity Manager for merging purposes. I have follow the same concept which mention from this blog however I received null pointer exception of my entity manager. I guess something missing which doens't mention from the step above. 

Below is my partially code and implementation:

HibernateSessionMergeConverter:
...
@Repository
public class HibernateSessionMergeConverter implements TypeConverter {

	private EntityManager entityManager;

    @PersistenceContext
    public void setEntityManager(EntityManager entityManager) {
        this. entityManager = entityManager;
    }

    ...    

    public Object coerceToUi(Object val, Component comp) {
    	
    	if(val instanceof GenericBean){
    		entityManager.merge(val);
    	}
    	return val;
    }
...

JPA Context XML:





    
       
    

    
        
    

    
       



Your help and consideration is highly appreciated. Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Hi all, I am currently using Spring JPA to inject my Entity Manager for merging purposes. I have follow the same concept which mention from this blog however I received null pointer exception of my entity manager. I guess something missing which doens&#039;t mention from the step above. </p>
<p>Below is my partially code and implementation:</p>
<p>HibernateSessionMergeConverter:<br />
&#8230;<br />
@Repository<br />
public class HibernateSessionMergeConverter implements TypeConverter {</p>
<p>	private EntityManager entityManager;</p>
<p>    @PersistenceContext<br />
    public void setEntityManager(EntityManager entityManager) {<br />
        this. entityManager = entityManager;<br />
    }</p>
<p>    &#8230;    </p>
<p>    public Object coerceToUi(Object val, Component comp) {</p>
<p>    	if(val instanceof GenericBean){<br />
    		entityManager.merge(val);<br />
    	}<br />
    	return val;<br />
    }<br />
&#8230;</p>
<p>JPA Context XML:</p>
<p>Your help and consideration is highly appreciated. Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Baker</title>
		<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/comment-page-1/#comment-141905</link>
		<dc:creator>Paul Baker</dc:creator>
		<pubDate>Wed, 14 Jan 2009 21:04:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2006/08/07/using-jpa-in-spring-without-referencing-spring/#comment-141905</guid>
		<description>Thanks Ben for this nice blog... I have a question for you...

Are JPA Annotations required to utilize the entityManager injection?

Background:
My ORM mappings are defined using hibernate hbm xml files and this is perfectly fine when running JPA on JBoss with the hibernate implementation.  However, when I try an inject the entityManager in my DAO pojo, as described above, I get a " is not mapped" error at runtime for any db access. The only difference in the code that works and does not work is where the entityManager is introduced.

If I use JPA annotations in the entity classes instead of the XML mappings... Then it does not matter where the entityManager is injected.

Any ideas?</description>
		<content:encoded><![CDATA[<p>Thanks Ben for this nice blog&#8230; I have a question for you&#8230;</p>
<p>Are JPA Annotations required to utilize the entityManager injection?</p>
<p>Background:<br />
My ORM mappings are defined using hibernate hbm xml files and this is perfectly fine when running JPA on JBoss with the hibernate implementation.  However, when I try an inject the entityManager in my DAO pojo, as described above, I get a &#034; is not mapped&#034; error at runtime for any db access. The only difference in the code that works and does not work is where the entityManager is introduced.</p>
<p>If I use JPA annotations in the entity classes instead of the XML mappings&#8230; Then it does not matter where the entityManager is injected.</p>
<p>Any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian</title>
		<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/comment-page-1/#comment-126867</link>
		<dc:creator>Adrian</dc:creator>
		<pubDate>Wed, 29 Oct 2008 11:42:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2006/08/07/using-jpa-in-spring-without-referencing-spring/#comment-126867</guid>
		<description>Because of the lack of multiple persistence units handling in spring, I'm using a EntityManagerFactory instance in my DAOs and getting the EntityManager's instance with entityManagerFactory.createEntityManager().
For some reason, transactions never commit.
Here is the chain: some client calls some service method. The service method is annotated with @Transactional. The service method calls one or more DAO methods performing CRUD. 
When returning from the service method, nothing is commited into the database. 


When using JpaDaoSupport (which I don't want) with the same spring configuration, everything works fine.

Why?

    
        
        
        
    
    
        
        
        
        
    
    
        
    
    </description>
		<content:encoded><![CDATA[<p>Because of the lack of multiple persistence units handling in spring, I&#039;m using a EntityManagerFactory instance in my DAOs and getting the EntityManager&#039;s instance with entityManagerFactory.createEntityManager().<br />
For some reason, transactions never commit.<br />
Here is the chain: some client calls some service method. The service method is annotated with @Transactional. The service method calls one or more DAO methods performing CRUD.<br />
When returning from the service method, nothing is commited into the database. </p>
<p>When using JpaDaoSupport (which I don&#039;t want) with the same spring configuration, everything works fine.</p>
<p>Why?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shalini</title>
		<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/comment-page-1/#comment-122110</link>
		<dc:creator>Shalini</dc:creator>
		<pubDate>Mon, 22 Sep 2008 16:49:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2006/08/07/using-jpa-in-spring-without-referencing-spring/#comment-122110</guid>
		<description>I'm not able to get the EntityManager.it gives me null.</description>
		<content:encoded><![CDATA[<p>I&#039;m not able to get the EntityManager.it gives me null.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julien</title>
		<link>http://blog.springsource.com/2006/08/07/using-jpa-in-spring-without-referencing-spring/comment-page-1/#comment-115178</link>
		<dc:creator>Julien</dc:creator>
		<pubDate>Wed, 30 Jul 2008 14:05:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.interface21.com/main/2006/08/07/using-jpa-in-spring-without-referencing-spring/#comment-115178</guid>
		<description>With this example I'm interesting to know how you could manage some error, like some duplicate entry that you would try to make a retry on the entity but with an other generated value for the unique property...  I tryed some aop interception or to catch some errors on my side but this get me some problems and put transactions errors...

Do you have any idea on how to manage such errors ?

Thanks

Julien</description>
		<content:encoded><![CDATA[<p>With this example I&#039;m interesting to know how you could manage some error, like some duplicate entry that you would try to make a retry on the entity but with an other generated value for the unique property&#8230;  I tryed some aop interception or to catch some errors on my side but this get me some problems and put transactions errors&#8230;</p>
<p>Do you have any idea on how to manage such errors ?</p>
<p>Thanks</p>
<p>Julien</p>
]]></content:encoded>
	</item>
</channel>
</rss>
