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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:31:34+00:00 2026-05-19T01:31:34+00:00

In an attempt to find another issue, my tests came up with the following

  • 0

In an attempt to find another issue, my tests came up with the following bit of code.

public class TestPersistance {
 private static final PersistenceManagerFactory PMF = JDOHelper.getPersistenceManagerFactory("datanucleus.properties");
 public static final PersistenceManager pm = PMF.getPersistenceManager();
 static final TestUserDataDB ud = new TestUserDataDB();

 public static void main(String args[])
 {
  TestPersistance tp = new TestPersistance();
  tp.createData();
 }

  @Test  public void createData()
 {
  assertTrue("Null machined id at start", ud.machineId != null);
  pm.currentTransaction().begin();
   try
   {
  pm.makePersistent(ud);
   }
   finally
   {
  pm.currentTransaction().commit();
   }
   assertTrue("Null machined id at end", ud.machineId != null);
 }
}

where the second assert fails. ie. my object that I am asking to be persisted is being changed by the makePersistent call. The data is being stored in the database.
Any ideas? Can any one confirm this.
using
jdo-api-3.0.jar
datanucleus-core-2.2.0-release.jar
datanucleus-enhancer-2.1.3.jar
datanucleus-rdbms-2.2.0-release.jar
mysql-connector-java-5.1.13.jar

in eclipse with MySql database.

@PersistenceCapable
public class TestUserDataDB {

 @PrimaryKey
 @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
 public Long id;

 @Persistent
 public String userid = "test1";
 @Persistent
 public String machineId = "test2";

 // local userid
 @Persistent
 public long uid = 1L;

 @Persistent
 public long systemTime = 123L;
 public long chk = 1234L;
 public long createTime = System.currentTimeMillis();

 public TestUserDataDB()
 {
 }

 @Override
 public String toString() {
  return "TestUserDataDB [chk=" + chk + ", createTime=" + createTime
    + ", id=" + id + ", machineId=" + machineId + ", systemTime="
    + systemTime + ", uid=" + uid + ", userid=" + userid + "]";
 }



}

Properties file is

javax.jdo.PersistenceManagerFactoryClass=org.datanucleus.jdo.JDOPersistenceManagerFactory
datanucleus.metadata.validate=false

javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
javax.jdo.option.ConnectionURL=jdbc:mysql://localhost/test
javax.jdo.option.ConnectionUserName=root
javax.jdo.option.ConnectionPassword=yeahRight
datanucleus.autoCreateSchema=true
datanucleus.validateTables=false
datanucleus.validateConstraints=false
  • 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-19T01:31:35+00:00Added an answer on May 19, 2026 at 1:31 am

    Why are you accessing fields directly ? Is the accessing class declared as PersistenceAware ? Well it isn’t so you can’t do that – use the getters.
    What is “ud” object state before persist ? (transient?) what is it after persist ? (hollow?) What does the log say ? Chances are that it is in hollow state and then you access a field directly and it has no value (by definition, as per the spec) … but since you didn’t bother calling the getter it hasn’t a chance to retrieve the value. And you likely also don’t have “RetainValues” persistent property set

    Suggest you familiarise yourself with the JDO spec and object lifecycle states

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

Sidebar

Related Questions

When I attempt to deserialize: { tags: {} } into: public static class Foo
In the book Learn Objective-C on the Mac' you can find the following code
I attempt to use webservice return POCO class generated from entity data model as
The following is my attempt at a prepare statement. It is causing the page
I tried to reproduce the attempt to make a capture of a window following
I'm having the above issue when I attempt to set a string (stored in
where can I find the realization code of the function __swtch_pri ? void __spin_lock_solid
Problem: find ids that are in one file but not in another. Each file
I'm a bit of a Linq newbie, and I couldn't find any documentation to
I have the following scenario: a Bitmap that is used as background and another

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.