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 5846859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:38:11+00:00 2026-05-22T12:38:11+00:00

I am currently working on a Java EJB project being deployed to Weblogic 10.3.3.

  • 0

I am currently working on a Java EJB project being deployed to Weblogic 10.3.3. We are using JPA 1.0 with Hibernate 3.4 as the implementor. We are also using the Oracle10g Dialect.

The issue we are running in to involves the generation of SQL by hibernate when attempting to lock a row for update.

We execute a query:

Query q = entityManager.createNamedQuery("findMyObject");    
MyHibernateObject myObject= (MyHibernateObject ) q.getSingleResult();

And then lock that object with:

entityManager.lock(myObject, LockModeType.WRITE);

This act of locking generates the query:

SELECT myObject FROM myTable FOR UPDATE NOWAIT

What I want it to generate is:

SELECT myObject FROM myTable FOR UPDATE

Enabling other threads to query for this object without throwing the exception: org.hibernate.exception.LockAcquisitionException and to just wait their turn or let the EJB transaction timeout.

So knowing all this, can I force Hibernate to generate the SQL without the NOWAIT keyword?

I know that using Hibernate 3.6 and JPA 2.0 will allow this using a pessimistic lock but due to Weblogic only supporting JPA 1.0 our hands are tied.

Ideally I want to avoid writing our own retry and/or timeout mechanism by handling the exception when all I need is to just augment the SQL that Hibernate is generating when the EntityManager creates the lock.

  • 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-22T12:38:12+00:00Added an answer on May 22, 2026 at 12:38 pm

    Ok, we are using a workaround until we update to Weblogic 10.3.4

    Here it is in case someone else stumbles upon this:

    SessionImpl session = (SessionImpl)entityManager.getDelegate();
    session.lock(myObject, LockMode.UPGRADE);
    

    This of course breaks from the JPA standard, in that we are exposing hibernates implementation and using the hibernate session.

    But it will generate a

    SELECT myObject FOR UPDATE
    

    instead of

    SELECT myObject FOR UPDATE NOWAIT
    

    Hope this helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working on a Java EE 6 project (EJB 3.1, JSF 2, JPA
I'm currently working on a Java project that is emitting the following warning when
I am coming from Java and am currently working on a C# project. What
I'm currently working on a WebSphere 6.1 Web Project. In my java code, how
I'm currently working on a hobby project, written in Java, containing about two different
I'm currently working on a Java project which uses Tibco rendezvous control. I have
I am currently working on a project with multiple ejb and one ejb-jar.xml. I
I'm currently working on a project that is done in Java, on google appengine.
I'm currently working with a specialized, interpreted, programming language implemented in Java. As a
I'm working on a cross platform application in Java which currently works nicely on

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.