Still reviewing code :)
So I'm looking over this, and it seems like within one
DistributedBrokerImpl, you can only persist against one slice. Since
the _rootSlice is set on the very first object that it tries to persist,
and never again.
So I'm new here, so I am assuming that one Broker is used per
EntityManager, but what if I want to use one EntityManager to persist
two kinds of objects that live in different slices.. am I just reading
this wrong?
The persist would be called on object A, the the persist would be called
on object B, but it would use the rootSlice determined by A?
Or is a broker used once per transaction. But even then I might want to
create an object A and object B within the same "transaction".
please help.
/**
* Assigns slice identifier to the resultant StateManager as
initialized by
* the super class implementation. The slice identifier is decided by
* [EMAIL PROTECTED] DistributionPolicy} for given <code>pc</code> if
it is a root
* instance i.e. the argument of the user application's persist() call.
The
* cascaded instances are detected by non-empty status of the current
* operating set. The slice is assigned only if a StateManager has never
* been assigned before.
*/
@Override
public OpenJPAStateManager persist(Object pc, Object id, boolean
explicit,
OpCallbacks call) {
OpenJPAStateManager sm = getStateManager(pc);
String[] targets = null;
boolean replicated = SliceImplHelper.isReplicated(sm);
if (getOperatingSet().isEmpty()
&& (sm == null || sm.getImplData() == null)) {
targets = SliceImplHelper.getSlicesByPolicy(pc,
getConfiguration(),
this);
if (!replicated) {
_rootSlice = targets[0];
}
}
sm = super.persist(pc, id, explicit, call);
if (sm.getImplData() == null) {
if (targets == null) {
targets = replicated
? SliceImplHelper.getSlicesByPolicy(pc,
getConfiguration(), this)
: new String[]{_rootSlice};
}
sm.setImplData(targets, true);
}
return sm;
}