Re: 2.1 Spec: detached-dirty parameters to makePersistent() when DetachAllOnCommit=tru
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache JDO Project > Re: 2.1 Spec: detached-dirty parameters to makePersistent() when DetachAllOnCommit=tru




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: 2.1 Spec: detached-dirty parameters to makePersistent() when DetachAllOnCommit=tru  
cbeams


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-06-07 06:11 AM

My previous email on this topic was a bit verbose, and I later
realized contained some inaccuracies.  Keeping things as succinct as
possible, is there any reason the spec couldn't be amended to support
the following code?


package com.xyz;

import org.apache.log4j.Logger;

import javax.jdo.*;
import static javax.jdo.JDOHelper.*;


public class Main {
public static final Logger logger = Logger.getLogger(Main.class);

public static void main(String... args) {
PersistenceManagerFactory pmf =
JDOHelper.getPersistenceManagerFactory("jpox.properties");
PersistenceManager pm = pmf.getPersistenceManager();

assert pm.getDetachAllOnCommit() == true;

A parameter = new A();
A returned;

logger.info("making newly created parameter instance
persistent");
pm.currentTransaction().begin();
returned = pm.makePersistent(parameter);
pm.currentTransaction().commit();

assert parameter == returned;
assert isDetached(parameter) && !isDirty(parameter);

logger.info("dirtying parameter instance");
parameter.setName("mud");
assert isDetached(parameter) && isDirty(parameter);

logger.info("reattaching dirtied parameter instance");
pm.currentTransaction().begin();
returned = pm.makePersistent(parameter);
pm.currentTransaction().commit();

// these assertions currently fail
assert parameter == returned;
assert isDetached(parameter) && !isDirty(parameter);
}
}


@javax.jdo.annotations.PersistenceCapable(detachable = "true")
class A {
private String name;
public void setName(String name) { this.name = name; }
}


Thanks,

- Chris Beams









[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:47 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register