entitymanager « JPA « Spring Q&A





1. Spring, Hibernate & JPA: Calling persist on entitymanager does not seem to commit to database    stackoverflow.com

I'm trying to setup Spring using Hibernate and JPA, but when trying to persist an object, nothing seems to be added to the database. Am using the following:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
   ...

2. Spring DaoSupport and @PersistanceContext EntityManager?    stackoverflow.com

One of the most difficult things about understand Spring is that Spring supports multiple approaches to the same problem. So in my application I using injected EntityManager using the @PersistanceContext annotation, for ...

3. In Spring, how do I use a ClassPathXmlApplicationContext to get an EntityManager?    stackoverflow.com

With Spring I can autowire a bean with the following property:

@PersistenceContext(unitName="foo") private EntityManager em;
Using the following I can manually autowire the bean "someBean":
ClassPathXmlApplicationContext ctx = 
      ...

4. Spring + Hibernate + JPA    stackoverflow.com

As of now I have a working Spring application with persistence. However now I want to use Hibernate with JPA to do all of my database activities. I want to do ...

5. EntityManager refresh problem    stackoverflow.com

I'm getting this error from my EntityManager when I call the refresh function.

public void saveProduct(Product product) {
    entityManager.refresh(product);
}
I heard this could be a bug with Spring/Hibernate, however I'm ...

6. EntityManager merge/persist problem    stackoverflow.com

I'm having this strange problem where my merge() or my persist() functions are not being reflected in the database. My JdbcProductDao.java:

@Repository("productDao")
public class JdbcProductDao implements ProductDao {
    @PersistenceContext
  ...

7. JSF + Spring + JPA + Hibernate: keep entitymanager alive when rendering view?    stackoverflow.com

Totally new to Spring & Java development but working on a project for a class with some experienced developers. I believe we're using Spring MVC as our web layer(but I'm ...

8. Obtaining EntityManager without Spring    stackoverflow.com

I'm using hibernate but not Spring, and just found hibernate-generic-dao. The concept seems nice, but when I run it I get a NPE because I haven't called setEntityManager(). How do I ...

9. EntityManager and two DAO with PersistenceContextType.EXTENDED    stackoverflow.com

I have a problem with my entity manager in my application. I have two DAO clasess like this:

@Repository
public abstract class DaoA 
{
    protected ClassA persistentClass;

    ...





10. Spring EntityManager Hibernate Exception Handling    stackoverflow.com

In a Spring, JPA, Hibernate project I'm trying to get exception handling working. For the following code:

    @Repository("mscoutService")
    public class MScoutServiceImpl implements MScoutService, Serializable {

 ...

11. Does Spring support PersistenceContextType.EXTENDED?    stackoverflow.com

A @Stateful EJB can use PersistenceContextType.EXTENDED for reusing the same EntityManager across multiple transactions. This is useful in implementing conversational scopes. Does Spring have any support for this?

12. EntityManager persist() not saving anything to database    stackoverflow.com

My entityManager persist() gets id from sequence and puts it to my Image object but the Image object itself is not showing up in the database. EntityManager.flush() gives an error so ...

13. how to setup spring data jpa with multiple datasources    stackoverflow.com

I am using Spring Data Jpa version 1.0.0.M2 here is the url: http://static.springsource.org/spring-data/data-jpa/docs/1.0.0.M2/reference/pdf/spring-data-jpa-reference.pdf All is promised to be very simple and nice, but when it comes to two datasources it breaks ...

14. Issue configuring JPA entitymanager from Jboss 4.2.2 Spring 2 TO Jboss 6 Spring 3    stackoverflow.com

EntityManager is null (not injected) whith jboss6 spring 3 JPA2 hibernate trying to migrate an existing App running on Jboss4.2.2 Spring 2 to Jboss 6 Spring 3 Afer many try the App is correctly ...

15. entitymanager is null on DAO class    stackoverflow.com

I am trying to implement Spring MVC 3 +EclipseLink JPA 2 When I call saveUser for example it returns that

NullPointerException, EntityManager is null
:
public class UserDAO {
  @PersistenceContext
  ...

16. JPA & Spring- how to obtain the shared EntityManager from spring?    stackoverflow.com

I'm using JPA with Hibernate on Spring 3.0. I have defined a LocalEntityManagerFactoryBean and JpaTransactionManager. All the Daos have an EntityManager (i guess a shared one) injected with @PersistenceContext, but i have some ...





17. EntityManager configuration in each DAO    stackoverflow.com

I understand that this is a very long question, but i wanted to ask everything because i'm stuck with these things for more than 2 weeks and i'm in a situation to ...

18. EntityManager can Read But cant Persist objects in DB    forum.springsource.org

EntityManager can Read But cant Persist objects in DB greeting all. im new to Using JPA with spring. i have a problem when i want to persisting an object. its my ...

19. entitymanager remove update not working    forum.springsource.org

entitymanager remove update not working I have the following in a main method Code: EventLog entity = ObjectManager.EVENT_LOG_DAO.findById(4L); try { ObjectManager.EVENT_LOG_DAO.remove(entity); } catch (RemoveException ex) { LOGGER.debug("Error while removing object", ex); ...

20. JPA 2 entitymanager closing too soon    forum.springsource.org

JPA 2 entitymanager closing too soon Hi all I have a problem with getting an entity to update in db(MYSQL). My current setup is Spring 3.0.5 JPA 2 (Hibernate 3.6) running ...

21. @PersistenceContext: When the Extended-EntityManager gets closed??    forum.springsource.org

@PersistenceContext: When the Extended-EntityManager gets closed?? Hello everybody, If an EntityManager gets injected into a dao object using the @PersistenceContext annotation, this EM is, by default, a transaction-EM and, hence, it ...

22. JPA entityManager is null in Pointcut    forum.springsource.org

JPA entityManager is null in Pointcut I have defined a pointcut using the @Aspect annotation in my class. I configure the pointcut using a custom annotation which I have defined in ...

23. EntityManager.flush() is not immediately committing to db with JPATransactionManager    forum.springsource.org

EntityManager.flush() is not immediately committing to db with JPATransactionManager In a unit test class that extends AbstractTransactionalTestNGSpringContextTests, I have @PersistenceContext(type= PersistenceContextType.TRANSACTION) protected EntityManager em; @Rollback(false) @Transactional(propagation= Propagation.REQUIRED) public void test1() { ...

24. entityManager not suspended when @Transactioanl( REQUIRES_NEW )    forum.springsource.org

entityManager not suspended when @Transactioanl( REQUIRES_NEW ) I'm looking for a way to have Spring bind a new entityManager in the EntityManagerHolder for methods marked @Transactional( propagation = Propagation.REQUIRES_NEW ) suspending ...

25. EntityManager in multi threaded application    forum.springsource.org

EntityManager in multi threaded application Scenario: we uses Spring in a Multi Threaded application (no gui) for implementing the persistence layer. We will have one service class, which have methods marked ...

26. Why we need "transient EntityManager"?    forum.springsource.org

THe objects can get serialized in the httpsession (when used as formobjects for instance) and you really don't want to serialize your entitymanager... Hence the transient... It will be reinjected after ...

27. EntityManager not persisting to database    forum.springsource.org

EntityManager not persisting to database I'm not receiving any errors or exceptions but the data I'm persisting is not being stored in the database. I'm using Spring with JPA and annotations ...

28. Get EntityManager by getBean from ApplicationContextAware    forum.springsource.org

Get EntityManager by getBean from ApplicationContextAware Hi everyone Today I have got my entityManager implemented like this (This is my full data xml file) Code:

29. Retrieve Connection from entitymanager    forum.springsource.org

Hi All, I'm using Spring 3, Hibernate & JPA 1 for my web app & mysql as the DB server I want to retrieve the native Connection object from the entitymanager. ...

30. deployment issues: "Could not open JPA EntityManager" only on server    forum.springsource.org

deployment issues: "Could not open JPA EntityManager" only on server I have a Debian 5 server where I run 2 sites on Apache Tomcat 6.0.33 and MySQL 5.1.58. I use 2 ...

31. Hibernate EntityManager    forum.springsource.org

Hi, you referenced a blog entry I wrote a few weeks ago. I reposted an updated version in our team blog: http://blog.diefirma.de/2006-01-10/u...i-with-spring/ (taking the latest Spring and Hibernate version into account...) ...

32. How to integrate Spring and Hibernate Entitymanager?    forum.springsource.org

Is there any one has an example? Entitymanager would manage the transaction in Hibernate EntityManager. Is there any way to use Spring to manage it?

33. EntityManager in JpaDaoSupport    forum.springsource.org

EntityManager in JpaDaoSupport hey guys. Am using spring-framework-2.0-m2-with-dependencies-build.398-20060118.zip as a starting point for playing around with Hibernate EM and Spring support. Question: How do i get an EM from within a ...

34. Spring 2.0M3 with JPA + Hibernate EntityManager?    forum.springsource.org

Spring 2.0M3 with JPA + Hibernate EntityManager? I'm trying to prepare a skeleton for a web application using some yet-unreleased technologies: Spring 2.0 M3, JPA public draft, Hibernate 3.2 CR1, Hibernate ...

35. Downcast EntityManager    forum.springsource.org

Downcast EntityManager Hi, I'm using Spring 2.0rc1 with JPA (Hibernate impl). The EntityManager is injected using the @PersistenceContext annotation in my service layer: @PersistenceContext private EntityManager em; In some methods I ...

36. Hibernate EntityManager magic tidbits    forum.springsource.org

Hibernate EntityManager magic tidbits This is not a question, just a tidbit I have learned in playing with all kinds of JPA configurations using hibernate as the provider (see http://forum.springframework.org/showthread.php?t=26773 for ...

37. pointcut on entityManager    forum.springsource.org

pointcut on entityManager Hello, I am playing with spring 2 aop features, I try to intercept call to the 'persist' method of entityManager in order to do something with the instance ...

38. Shared EntityManager help    forum.springsource.org

im not an expert in JPA, but be aware of using shared entity manager. As i know, EntityManager acts as a "wrapper" of Session of Hibernate (if you use hibernate), that ...

39. Shared EntityManager in Weblogic    forum.springsource.org

Shared EntityManager in Weblogic I'm having trouble getting a Shared EntityManager working inside of Weblogic. I am able to test my code quite happily outside of the container using a JDBC ...

40. Odd problem with JPA / Hibernate Entitymanager and Spring 2.0    forum.springsource.org

Hi. I have an odd problem with @ManyToMany and hibernate entitymanager. I have two classes. Article and Tag. I want to have a Many to many relationship between these. When i ...

41. EntityManager in init method    forum.springsource.org

I assume your method is not transactional which means the em will be opened only for the duration of the method createQuery after which, it will be closed. For your case, ...

42. Problem with JPA and the EntityManager    forum.springsource.org

Feb 2nd, 2007, 01:21 PM #1 tbednarz View Profile View Forum Posts Private Message Member Join Date Jan 2007 Posts 34 Problem with JPA and the EntityManager What I am trying ...

43. JpaTemplate Exception using Hibernate EntityManager    forum.springsource.org

Hi, I am getting the following Exception when I try to perform a query from entiry manager: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not load an entity: [com.yadayada.domain.Filter#1] The code is: Code: public Filter ...

44. Unable to catch Persistence Exception if using EntityManager    forum.springsource.org

Unable to catch Persistence Exception if using EntityManager Hi, I'm using EJB3. As usual, i'll use the EntityManager's API to do CRUD operation, such as, em.persist(), em.merge() etc. The problem here ...

45. Thread safe entitymanager    forum.springsource.org

The answer to your question can be found in the following link: http://forum.springframework.org/showthread.php?t=33804 As far as I know the EntityManager can be compared to the Hibernate session, and the last one ...

46. Shared EntityManager with Hibernate in WebLogic Server    forum.springsource.org

Shared EntityManager with Hibernate in WebLogic Server I have a problem trying to get a SharedEntityManager for the life of a JTA transaction. I'm using hibernate-entitymanager-3.2.1.ga, spring-2.0.4 and WebLogic 9.2MP1 with ...

47. Getting java.sql.Connection from EntityManager with hibernate and JPA    forum.springsource.org

Getting java.sql.Connection from EntityManager with hibernate and JPA I am using hibernate 3 and JPA configured via Springs entity manager factory (see snippet from application-context.xml below). Unfortunately in one part of ...

48. Help:EJB3 entityManagerFactory or entityManager required    forum.springsource.org

Code: javax.ejb.EJBException: java.lang.IllegalArgumentException: entityManagerFactory or entityManager is required at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77) at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at ...

49. Scoping Shared EntityManager with Hibernate and Spring    forum.springsource.org

Scoping Shared EntityManager with Hibernate and Spring I'm using Spring (currently 2.0.6), Hibernate 3.2.3 and Hibernate-EntityManager 3.2.1 in WLS 9.2 MP2. The aim is to use Hibernate's JPA functionality with Spring ...

50. EntityManager is null??    forum.springsource.org

EntityManager is null?? Hi, I'm trying to create test application with Spring & JPA. Problem is that Spring DI doesn't work because it return null entityManager!! I've created everything as spring ...

51. Extended EntityManager / JpaTemplate    forum.springsource.org

Hi, I am using an Application Managed Entity Manager. I move to JpaTemplate because I want to use Spring. I configure my bean to have a JpaTemplate injected. However, I noticed ...

52. Using JPA @EntityManager    forum.springsource.org

Using JPA @EntityManager Hi all ! I'm working on a new project and want to use JPA as my main DAO. Using OpenJPA 1.0.1 and Spring 2.5 on Tomcat 6 here's ...

53. Spring 2.5 JBoss 4.2 EntityManager over JNDI    forum.springsource.org

Spring 2.5 JBoss 4.2 EntityManager over JNDI I work on a spring application which resides in the catalina container. The entityManagerFactory as well as the domain objects are located in the ...

54. CGLib unable to find Hibernate when loading EntityManager via Spring.    forum.springsource.org

Jan 30th, 2008, 01:42 AM #1 ryan.lea View Profile View Forum Posts Private Message Junior Member Join Date Aug 2006 Posts 6 CGLib unable to find Hibernate when loading EntityManager via ...

55. SharedEntityManagerCreator closes EntityManager prematurely    forum.springsource.org

SharedEntityManagerCreator closes EntityManager prematurely I am using JPA with spring and hibernate. I have a non-transactional method that creates and executes a read-only query. The SharedEntityManagerCreator.invoke is called to invoke the ...

56. Entitymanager VS. All others    forum.springsource.org

Entitymanager VS. All others Hi , i'm fairly new to jpa and have been able to learn so far only what i needed for work so please ebar with me , ...

57. Why my entityManager can create, execute a query but cannot merge and persist?    forum.springsource.org

Apr 29th, 2008, 06:10 PM #1 dxxvi View Profile View Forum Posts Private Message Member Join Date May 2006 Posts 67 Why my entityManager can create, execute a query but cannot ...

58. hibernate entityManager won't start    forum.springsource.org

hibernate entityManager won't start I've been trying to get a new site working with spring 2.5.4 and hiberate 3.2.6 using jpa. I get the following error when it I try to ...

59. i got a non functional entityManager proxy    forum.springsource.org

I would say you don't have a transaction manager configured. Configure one, together with some transactional configuration, read chapter 9 of the reference guide that covers transactions. DB access (at least ...

60. Null EntityManager    forum.springsource.org

Null EntityManager Hi Find/Update/Save is working fine for JPA, but when I try a 'select count(*)....' query, I need to use the Query object (from what I can tell) To do ...

61. JPA - Attempting to execute an operation on a closed EntityManager.    forum.springsource.org

JPA - Attempting to execute an operation on a closed EntityManager. I'm hoping some Spring gurus can help me out, whenever I try to execute a query I get the error: ...

62. Springs EntityManager.persist won't flush using JpaTransactionManager    forum.springsource.org

Springs EntityManager.persist won't flush using JpaTransactionManager I can't seem to get EntityManager.persist to work using JpaTransactionManager in Spring. My code does not generate any errors, but it doesn't write to the ...

63. EntityManager is null    forum.springsource.org

I couldn't add the dao classes code in the previous post. Here they come: Code: @Transactional public abstract class GenericDaoHibernate implements IGenericDao { private Class domainClass; @PersistenceContext ...

64. JPA EntityManager in Standalone Environment    forum.springsource.org

JPA EntityManager in Standalone Environment I've got a utility program that is giving me fits because there is no Hibernate session available for lazy loading. Having been on the grand adventure ...

65. EntityManager in Singleton and Concurrency    forum.springsource.org

I suggest you read the reference gudie explaining spring and JPA. The spring based EntityManager (which is basically a proxy) is a thread safe one.

66. Unable to get reference to EntityManager (spring+jpa+hibernate)    forum.springsource.org

Unable to get reference to EntityManager (spring+jpa+hibernate) Hi, I'm having trouble getting access to an EntityManager instance: When using @PersistenceContext - I get this exception on startup: Code: com.sun.enterprise.deployment.backend.IASDeploymentException: Deployment Error ...

67. AbstractJpaTests entityManager is null    forum.springsource.org

AbstractJpaTests entityManager is null hi all... i'm trying to setup tests using the AbstractJpaTests class. when executing my tests, the entityManager reference in my service is null and thus throws a ...

69. PersistenceContext/EntityManager not binded    forum.springsource.org

PersistenceContext/EntityManager not binded following the reference, I'm still in stuck on Spring+OpenJPA+Tomcat6 integeration. would you help me out, thank you. I do as follows, but it dose not work: 1. versions: ...

70. How to do a EntityManager.clear() in jpatemplate    forum.springsource.org

71. Using EntityManager functions in codes    forum.springsource.org

Using EntityManager functions in codes Hello, I am a newbie to Spring and Spring Batch. Currently using JBoss Seam Framework along with Hibernate for our web application. Like to re-use the ...

72. Lazy loading, EntityManager and concurrency.    forum.springsource.org

I need advice which strategy to use with lazy loading. My project is based on Spring, Struts 2 and Hibernate JPA. I have enough OneToMany and ManyToMany relationships and it's reasonable ...

73. Using EntityManager in existing sample code    forum.springsource.org

Using EntityManager in existing sample code Hello, I have been struggling to find the right way to use JPA EntityManager in one of the existing sample codes. For example here what ...

74. Sample codes using EntityManager    forum.springsource.org

Hello Gurus! The sample applications which comes with the Spring Batch 2.0.0 bundle are really great. If it is not to much to ask then it would be great to have ...

75. ClassCastException using Oracle EntityManager and JPA    forum.springsource.org

Sep 17th, 2009, 10:36 AM #1 sheadley View Profile View Forum Posts Private Message Junior Member Join Date May 2005 Posts 11 ClassCastException using Oracle EntityManager and JPA Hello all, I ...

76. getting EntityManager inside custom tag    forum.springsource.org

getting EntityManager inside custom tag Hi Friends, I am writing a custom tag as shown below. I am using JPA. I am trying to get a reference to my entityManager but ...

77. How would EntityManager work with multiple persistence units in different modules.    forum.springsource.org

How would EntityManager work with multiple persistence units in different modules. Hi, I have a query regarding JPA EM injection. As my knowledge goes, when a DAO instance (singleton) is asked ...

78. EntityManager refresh problem    forum.springsource.org

EntityManager refresh problem I'm using Spring with Hibernate and right now I'm getting this exception using the refresh function for EntityManager. Code: public void saveProduct(Product product){ entityManager.refresh(product); } The exception is: ...

79. EntityManager Null    forum.springsource.org

Hi Guys, I have been struggling to figure this out.I will appreciate if anyone can help me on this. I am initializing bean on start up with spring.Below is the entry ...

80. How to set up EntityManager with Hibernate's filters    forum.springsource.org

How to set up EntityManager with Hibernate's filters Hi, in our application, we're using (mostly) JPA for data access. We're using Hibernate's filters to filter data, which a user sees, according ...

81. entityManager always NULL;    forum.springsource.org

entityManager always NULL; Hi, I looked thru all the available info on this problem in the Internet, nothing applies to or work in my case. Any info and help will be ...

82. is entitymanager is thread safe ?    forum.springsource.org

I have the following configuration : ... From what you say, I can think that my entity manager is thread safe. Is it true ?

83. Dynamically decide on an EntityManager for a Repository    forum.springsource.org

Dynamically decide on an EntityManager for a Repository Hey guys, I've got a spring setup with 2 types of EntityManagerFactories, one for transaction scoped entity managers, one for extended entity managers. ...

84. entityManager problem    forum.springsource.org

Code: @Service @Transactional public class InitialIndexPerformer { @PersistenceContext transient EntityManager entityManager; @PostConstruct public void performInitialIndex() throws InterruptedException { // entityManager=entityManager.getEntityManagerFactory().createEntityManager(); Session session = (Session) entityManager.unwrap(Session.class); FullTextSession fullTextSession = Search.getFullTextSession(session); fullTextSession.createIndexer().startAndWait(); } ...

85. Dynamic JPA/Hibernate EntityManager configuration    forum.springsource.org

Dec 15th, 2010, 05:07 PM #1 scho31 View Profile View Forum Posts Private Message Junior Member Join Date Dec 2010 Posts 1 Dynamic JPA/Hibernate EntityManager configuration Hi, I'm currently using Spring+JPA/Hibernate+Oracle ...

86. Spring managed entitymanager    seamframework.org