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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:32:03+00:00 2026-05-19T09:32:03+00:00

I recently added Text field to one of my Entities that cannot be null.

  • 0

I recently added Text field to one of my Entities that cannot be null. I’d like to set a default value for it, so that all of the Entities that I stored before I added the field will be populated with an empty string. Is this possible with JDO?

  • 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-19T09:32:04+00:00Added an answer on May 19, 2026 at 9:32 am

    Yes, though not as trivially as you were probably expecting.

    Limitations

    1. Will time out if it
      takes more then 30 seconds
      ,
      unless you run it as a task, in which
      case it will time out if it takes
      more then 10 minutes
      .
    2. There’s no smarter way to get only
      the entities that need updated since
      you can’t query on a property that
      doesn’t exist
      .

    Workarounds

    1. You’ll want to look into the
      appengine-mapreduce project to
      get an implementation that can
      complete with more then 10 minutes
      wall-clock time.
    2. None known.

    Code

    void updateNullBarField() {
      final Text DEFAULT_BAR = new Text("bar");
    
      PersistenceManagerFactory pmfInstance = JDOHelper
        .getPersistenceManagerFactory("transactions-optional");
      PersistenceManager pm = pmfInstance.getPersistenceManager();
      Query query = pm.newQuery(Foo.class);
      @SuppressWarnings("unchecked")
      Collection<Foo> foos = pm.detachCopyAll((List<Foo>) query.execute());
    
      for (Foo foo : foos) {
        if (foo.bar == null) {
          foo.bar = DEFAULT_BAR;
          pm.detachCopy(pm.makePersistent(foo));
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently added a stored procedure to my SQL Azure database. I added that
I recently added a new mapicon_id field to my venue records which displays all
I have an Access table that I recently added an attachment field to. The
I recently added Autofac 2.6.2 to one of my ASP.NET MVC projet. I'm facing
I recently added CKEditor to my app and I would like to include my
I recently added a parameter to one of the method of a wcf. It
I noticed recently that the project files my text editors use (along with some
I recently added some css to my website, it works perfectly fine in all
I have a text field In that user can enter values from 1-10 at
I have just recently added our db schema into a VSTSDB project and one

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.