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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:47:23+00:00 2026-06-09T09:47:23+00:00

I am trying the following which is resulting in an additional update execution and

  • 0

I am trying the following which is resulting in an additional update execution and failing my tests.
I have an entity like this.

@Entity
@SqlResultSetMapping(name = "tempfilenameRSMapping",
        entities = { @EntityResult(entityClass = MyEntity.class) }, 
        columns = { @ColumnResult(name = "TEMPFILENAME") })
//The reason for this mapping is to fetch an additional field data through join.
@Table(name = "MY_TABLE")
public class MyEntity {

   @Id
   @Column(name="ID")
   private String id;

   @Column(name="NAME")
   private String name;

   @Column(name="DESC")
   private String description;

   @Column(name="STATUS")
   private String status;

   //follwed by getter setters

}

I am trying to do a retrieve with a native query. And for the retrieved entity, I execute a native update (the reason for native update is that I want to update just one single field). Note that I am not updating the retrieved entity directly.

What I observe is that my update is not getting executed properly. When I turn the TRACE on, I notice that on flush openJPA is executing an additional update query and therefore overriding my original update.

e.g.

SELECT M.ID, M.NAME, M.DESC, O.TEMPFILENAME FROM MY_TABLE M, OTHER_TABLE O WHERE M.ID = ?

UPDATE MY_TABLE SET STATUS = ? WHERE ID = ?

UPDATE MY_TABLE SET ID=?, NAME=?, DESC=?, STATUS=? WHERE ID = ?

What can I do to skip the auto-updation?

Edit:
Here are the routines we use for executing the queries.

The following routine returns a named native query sql.

public String getNamedNativeQuerySql(EntityManagerFactory emf, String qryName) {
    MetamodelImpl metamodel = (MetamodelImpl) emf.getMetamodel();
    QueryMetaData queryMetaData = 
    metamodel.getConfiguration().getMetaDataRepositoryInstance().getQueryMetaData(null, qryName, null, true);
    String queryString = queryMetaData.getQueryString();
    return queryString;
}

The code for retrieval:

Query query = entityManager.createNamedQuery("retrieveQry");
query.setParameter(1, id);
Object[] result = (Object[]) query.getSingleResult();
MyEntity entity = (MyEntity) result[0];
String tempFileName = (String) result[1];

The code for update that follows retrieval:

Query qry = entityManager.createNamedQuery("updateQry");
qry.setParameter(1, status);
qry.setParameter(2, entity.getId() );
qry.executeUpdate()

Edit:

I see the problem even without the update statement. OpenJPA is
executing an additional update query even if I do a simple find.

  • 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-06-09T09:47:24+00:00Added an answer on June 9, 2026 at 9:47 am

    The problem was with runtime enhancement. OpenJPA was unable to do a proper detection of dirty state with runtime-enhanced entities.

    It got resolved by doing a build time enhancement.

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

Sidebar

Related Questions

I have the following javascript class which I am trying to pass to an
I have the following jquery code which doesn't work quite right when trying to
I am trying to install ruby-mp3info. I have the following URL from which I
I have an interface which is used like the following: if (SUCCEEDED(pInterface->GetSize(&size)) { wchar_t
I was trying out the following code which actually saves the pdf file to
I am trying following, 1. Get response using Ajax from the users selection which
I am trying to solve the following question which was part of a programming
I'm trying to pause and play YouTube videos with the following code which is
I am trying to read the file with the following format which repeats itself
I am trying to search for files which matches following expression with sed [a-zA-Z0-9]{1,10}\s{1,5}\

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.