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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:11:09+00:00 2026-05-14T03:11:09+00:00

I am using JPA with openjpa implementation beneath, on a Geronimo application server. I

  • 0

I am using JPA with openjpa implementation beneath, on a Geronimo application server. I am also using MySQL database. I have a problem with updating object with nullable Date property. When I’m trying to merge entity with Date property set to null, no sql update script is generated (or when other fields are modified, sql update script is generated, but date field is ommited from it). If date field is set to some other not null value, update script is properly generated.

Did anyone have problem like that?

  • 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-14T03:11:10+00:00Added an answer on May 14, 2026 at 3:11 am

    OpenJPA makes certain assumptions when you’ve detached (and presumably serialized) an entity and then merge it back in.

    It’s usually the serialization that kicks in this kind of problem – when the entity is serialized OpenJPA loses its StateManager which tracks which fields were loaded. As a result when you merge the entity back in with a null value OpenJPA isn’t certain that the field was ever loaded and thinks it hasn’t been changed.

    There are a couple of options to fix this :

    You can configure OpenJPA to use a serializable StateManager – and it will keep track of which fields you’ve loaded. To do this add the following property to persistence.xml.

    <property name="openjpa.DetachState" value="loaded(DetachedStateField=true)"/>
    

    Or tell OpenJPA to load a set of fields before the entity is detached. OpenJPA will then know which fields were present and will handle a null value properly. Your options are to load the fetch-groups (an OpenJPA concept, but by default it loads all non-LAZY fields), or every field (this can be expensive).

    I’d recommend fetch-groups in most cases, here’s the property for persistence.xml.

    <property name="openjpa.DetachState" value="fetch-groups"/>
    

    You can do some clever things with detached object graphs if you’re so inclined. The OpenJPA manual has more information at http://openjpa.apache.org/builds/1.2.2/apache-openjpa-1.2.2/docs/manual/manual.html#ref_guide_detach_graph

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

Sidebar

Related Questions

I'm using JPA 2 with Hibernate 3.6.8 as the implementation. Let's say we have
I'm using WebSphere 7 and their JPA 2.0 implementation which is based on OpenJPA,
I am using JPA (Hibernate) to store an entity on a MySQL 5.0 server.
We have a batch application using OpenJPA. We are specifying all the DB connection
I have doubt using jpa. I defined the datanucleus connection for MYSQL as follows.
I have a web application using JPA and JTA with Spring. I would like
I'm using WebSphere 7 (Java EE 5) and OpenJPA 1.2.1. I have a JPA
In pom.xml I have (taken from http://struberg.wordpress.com/2012/05/10/using-jpa-in-real-projects-part-1/ ): <properties> <openjpa.sql.action>refresh</openjpa.sql.action> <database.driver.name>org.postgresql.Driver</database.driver.name> <database.connection.url>jdbc:postgresql://myURL</database.connection.url> <database.user>user</database.user> <database.password>password</database.password>
I'm using Jpa with GAE. I have an Entity with collection of sub Entity
Is there any jpa 1.0 fluent api/interface for query building? I'm using openjpa 1.x,

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.