Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6531737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:54:52+00:00 2026-05-25T09:54:52+00:00

I understand that this is a very long question, but i wanted to ask

  • 0

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 solve this within
this week. Please guide me in this matter.

I’m Using EclipseLink jpa version 2, Spring 3, jdk6, MySQL5 and tomcat7.

I have configured the following in each of my DAO classes.

@PersistenceContext
private EntityManager em;

I have the following in my Spring xml:

<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"  id="dataSource">
    <property name="url" value="jdbc:mysql://localhost:3306/xxxxx"/>
    <property name="username" value="xxxx"/>
    <property name="password" value="xxxx"/>
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
</bean>

<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
    <property name="dataSource" ref="dataSource"/>
    <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
    <property name="jpaDialect" ref="jpaDialect"/>
</bean>

<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    <property name="jpaDialect" ref="jpaDialect"/>
</bean>

<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter" >
    <property name="showSql" value="true"/>
    <property name="generateDdl" value="true" />
</bean>

<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect"/>

From Persistence.xml:

<persistence-unit name="xxxxx" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<-- class mappings -->
</persistence-unit>

I’ve got few confusion about what i have done:

  1. Is the EntityManager injected by Spring? (I understand that @PersistenceContext is a
    J2EE annotation, so wondering whether it is injected without Spring’s contribution).

  2. As i have already mentioned, i have injected EntityManager in all the DAO classes. Is
    this a good practice? or should i make it Singleton by having a separate class like
    PersistenceManager, which has EntityManager attribute wired, and have
    getEntityManager() method?

  3. As you can see above, i have configured Spring transactions. But when i do CRUD
    operations continuously for 2-3 times, application gets stuck and fails with EclipseLink
    exception saying unable to get lock, timeout etc. Am i doing anything wrong here or
    missing any transaction configurations??

  4. With the above configurations, i can only use @Transactional annotation with default
    values which are PROPAGATION_REQUIRED,ISOLATION_DEFAULT. If i change these for any other
    values, such as @Transactional(PROPAGATION_REQUIRED,ISOLATION_SERIALIZABLE) etc,
    application throws exception as Custom isolation levels are not supported. Again, am
    i missing any configurations?

    Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:54:52+00:00Added an answer on May 25, 2026 at 9:54 am
    1. Yes, spring recognizes the @PersistenceContext annotation and injects the entity manager
    2. Spring takes care of that – it injects the same EntityManager instance in all DAOs. In fact, it injects a proxy so that each request uses a different entity manager.
    3. Normally everything should run fine. You need <tx:annotation-driven /> in order to use @Transactional
    4. JPA only supports the default isolation level. You can work this around by customizing the spring jpa dialect, but there’s nothing built-in. The way to go is extend XJpaDialect (in your case X=EclipseLink), override the beingTransaction, obtain the Connection (in an eclipse-link specific way), set the desired isolation level (accessible through the transaction definition), and configure this as a property of your LocalContainerEntityManagerFactoryBean:

      <property name="jpaDialect">
          <bean class="com.foo.util.persistence.EclipseLinkExtendedJpaDialect" />
      </property>
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that this is a very broad question, but a short it depends
I am very new to Silverlight development. I understand that this is client side
I understand that this question may be subjective, this is why I need an
I understand that this question could be answered with a simple sentence and that
I understand that 2 options are available: Non-persistent Persistent But what does this actually
This is a short question. At some point my thread understand that it should
I found this question here: OLEDB v/s ODBC Which gave me more information, but
I have a question very similar to this one but the answer does not
As a more general case of this question because I think it may be
Hey guys sorry this is a pretty long question but I cannot call printPASSInfo()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.