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

  • SEARCH
  • Home
  • 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 6786685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:16:31+00:00 2026-05-26T17:16:31+00:00

I am having a performance problem with JavaDB (Derby) writing transactions. Each transaction takes

  • 0

I am having a performance problem with JavaDB (Derby) writing transactions. Each transaction takes more than 500ms and I might have hundreds of thousands a day. I am expecting to deploy on MySql and I don’t know if I am going to have the same problem there, but I am trying to improve the performance on Derby before trying it.

One transaction involves updating a string of records — as many as 6 like so:

public void update(List<Tally> list) {
    try {
        utx.begin();
        for (Tally tally : list) em.merge(tally);
        utx.commit();
    // etc

I wanted to see if an UPDATE query would work better, since JPA wouldn’t have to keep track of the columns that updated and compose a SQL query (side question: is this a good theory?)

So I coded a named query that looks like this:

@NamedQuery(name="TallyUpdate",
   query="UPDATE Tally t SET t.vote = t.vote + 1 WHERE t.id IN :idSet"

That is operated like this:

@PersistenceContext protected EntityManager   em;
@Resource           protected UserTransaction utx;    
public void incrementVote(List<Long> idList) {
    Query q = em.createNamedQuery("TallyUpdate");
    q.setParameter("idSet", idList);
    try {
        utx.begin();
        q.executeUpdate();
        utx.commit();
    //etc

THE executeUpdate() call always throws an exception:

SEVERE: javax.persistence.TransactionRequiredException: executeUpdate is not supported for a Query object obtained through non-transactional access of a container-managed transactional EntityManager
    at com.sun.enterprise.container.common.impl.QueryWrapper.executeUpdate(QueryWrapper.java:225)

The JPA implementation is EclipseLink 2.3.0

What does that word-salad exception mean and how am I supposed to run the update?

RESULT POSTING:

I did move the createnamedQuery() call to after the utx.begin() call and the update started working. I am not sure why but I am going to run with it for now.

No result yet regarding the relative performance, but my posting above is misleading. When a vote is tallied it is tallied about 24-36 different ways, not 6. So there are six calls to the original update() method (which uses merge()) each with a list of about 6 records. It is this collection of calls that take more than 500ms. If the Tally table is empty then that benchmark is only about 27ms, which is about the speed I would like to see. The 500ms+ number is what I see when the table fills to 50,000 rows or more.

If anyone is interested in me posting the results of where I end up on this, please comment saying so.

P.S. this is a JSF application running under GlassFish, not EJB. I am not sure if there is any implication of that related to performance.

  • 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-26T17:16:32+00:00Added an answer on May 26, 2026 at 5:16 pm

    Since you have a container managed entity manager I’m guessing you have the thing injected into an EJB. Since that’s the case that means that the transactions are managed by the container, i.e. you do not need to start them explicitlly in your code. By default a transaction start when an EJB method starts and ends when that method finishes. That’s for stateless EJBs. For statefull EJBs the transaction can span multiple method calls, and end when the EJB “destroy” methods is called. So you should decide: you either use a container-managed entity manager (one injected into an EJB, as you have here) and you let the container manage the trasactions (via JTA) or you make an application-managed entity manager and you handle the transactions yourself in the code.

    Regarding performance the Apache guys say Derby is perfectlly good for production, matching and sometimes even surpassing MySQL and PostgreSQL in certain scenarios as you can see in this Apache document:

    http://home.online.no/~olmsan/publications/pres/apachecon05us/apachecon05.pdf

    Take that with a grain of salt, Derby is not world renouned for its performance. And even this document shows that in certain situations Derby is a lot slower than MySQL. Also the CPU usage is bigger on Derby.

    My advice: make a proof of concept aganins MySQL and do your benchmarks on that database. If that’s what you’re gonna use in production, it doesn’t make much sense to do performance tune-ups of your app on a different database.

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

Sidebar

Related Questions

I'm writing a plug-in for another program in C#.NET, and am having performance issues
I'm having a major performance issue with LINQ2SQL and transactions. My code does the
I have a strange performance problem with a query used to create a filter
In one of the apps of mine I have a performance problem I can’t
I have a self-hosted WCF service and I'm having the following problem: 15 minutes
I am having a performance problem binding a large string to a a TextBox
I'am currently having a slow performance problem with a SQL inner join on two
i am currently having a problem, i guess a lot of people have run
We are having a performance problem in our application - particularly when the browser
I have been having trouble with the WPF DataGrid and listbox GridView performance when

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.