Hey All,
Heres my basic scenario. Ive got an entity called a CARule entity.
For some of these rules the value attribute contains a department
number which should equal the primary key value of a related entity
called CADept (which is read-only entity). So I created this method
in the CARule.java class to get the CADept related object (if there
is one). It works fine, but the problem is that the value is not
cached.. I log out the sql and it is fetching nearly every time for
the same editing context. What am I missing? I thought it would
essentially fetch once and be cached thereafter. It is all in a
standard ERXEC editing context without any special settings.
/**
* A method to get the CADept object related to this rule. It will
* return null unless it is the appropriate type of role
*/
public CADept dept(){
CADept dept = null;
if (isDeptLeafRule()){
EOGlobalID gid = EOKeyGlobalID.globalIDWithEntityName(
CADept.ENTITY_NAME, new
String[]{value()});
System.out.println("Fetching " + value() + " in ec " +
editingContext());
dept = (CADept)editingContext().objectForGlobalID(gid);
if ( dept == null){
//dept = (CADept)ERXEOGlobalIDUtilities.fetchObjectWithGlobalID
(editingContext(), gid);
// I tried the above as well and still didn't get the caching I
wanted.
dept = (CADept)editingContext().faultForGlobalID(gid,
editingContext());
// Could be a bad rule if the value does not equal to a know dept
number
// trigger the fault here and catch it.
try{
System.out.println("Triggering "+value()+" in ec: " +
editingContext());
dept.deptName();
}catch (ObjectNotAvailableException e){
log.error("Rule has dept value of " +
value()
+ " which is not in
common_dept!", e);
dept = null;
}
}else{
System.out.println("Got the dept " + value() + "
directly");
}
}
return dept;
}
Thanks in advance for any help on this (particularly on my
understanding of caching, I know I can do some workarounds to make
the app more efficient but I'm trying to avoid my tendency to do that
here)
-- Jonathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]