You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Gary Jarrel <ga...@gmail.com> on 2011/03/29 14:40:23 UTC

Hollow object throwing FaultFailureException

Hi Guys,

There was a thread back in July 09
(http://mail-archives.apache.org/mod_mbox/cayenne-user/200910.mbox/%3C89FAAF97-90C2-4EF4-AE60-C8E57360AB30@gmail.com%3E)
in relation to hollow objects throwing a FaultFailureException. It
appears that the solution was to invalidated the parent object before
trying to use the one to one relationships of that object. I'm trying
to do this in a very simple environment and it appears that the
solution is not working.

Basically what I have is a ScheduledTask object which has a taskId
field which I have to set manually (usually a UUID). There is also the
scheduling system (Quartz) which is responsible for scheduling the
tasks using it's own set of tables. The Quartz database is also mapped
in my Cayenne Data Map. There is a one to one relationship from the
ScheduledTask to QuartzJobDetails via the taskId field.

I have a service class which is responsible for scheduling the task
which looks something like:

ScheduledTask task = this.scheduledTaskDao.createObject();
String taskId = UUID.randomUUID().toString();
task.setTaskId(taskId);
scheduledTaskDao.commit();

JobDetail job = new JobDetail(taskId, "test_group", TestJob.class);
SimpleTrigger trigger = new SimpleTrigger(taskId, startTime);
qScheduler.scheduleJob(job, trigger);

scheduledTaskDao.clearCache(Collections.singletonList(task))
//basically does ObjectContext.invalidateObjects()
return task;

Ignoring for a moment the fact that this is done in two different
transactions, when I call task.getQuartzJobDetails(), I get back a
hollow object QuartzJobDetails and when I try to access any fields
within this object I  get:

org.apache.cayenne.FaultFailureException: [v.3.0.1 Sep 06 2010
15:09:38] Error resolving fault for ObjectId:
<ObjectId:QuartzJobDetails,
JOB_NAME=730c2cbb-a994-4f0b-a251-da49d94be9ae> and state (hollow).
Possible cause - matching row is missing from the database.

I know for a fact that the row exists in the database and I can
actually run a Cayenne SelectQuery which easily finds the
QuartzJobDetails with ID 730c2cbb-a994-4f0b-a251-da49d94be9ae but my
task can never resolve this object correctly.

Can anyone give me any assistance?

Thank you

Gary

Re: Hollow object throwing FaultFailureException

Posted by Gary Jarrel <ga...@gmail.com>.
Sorry guys further to my previous post I've just noticed that the
quartz_job_details table has a Primary Key which consists of job_name
(which is the same as my taskId) and job_group. Now if I unset the
job_group field as a primary key then everything works and no
exceptions are thrown, however when the job_group is set creating a
compound key then the exception is thrown. Is there any way around
this?

Basically the hack that I have done so far is I overrode the
getQuartzJobDetail method as follows:

public QuartzJobDetails getQuartzJobDetail() {
	QuartzJobDetails details = super.getQuartzJobDetail();
	if(details.getPersistenceState() == PersistenceState.HOLLOW) {
	    return (QuartzJobDetails)
DataObjectUtils.objectForPK(getObjectContext(),
details.getObjectId());
	}

	return details;
}

Thank you

Gary

On Tue, Mar 29, 2011 at 11:40 PM, Gary Jarrel <ga...@gmail.com> wrote:
> Hi Guys,
>
> There was a thread back in July 09
> (http://mail-archives.apache.org/mod_mbox/cayenne-user/200910.mbox/%3C89FAAF97-90C2-4EF4-AE60-C8E57360AB30@gmail.com%3E)
> in relation to hollow objects throwing a FaultFailureException. It
> appears that the solution was to invalidated the parent object before
> trying to use the one to one relationships of that object. I'm trying
> to do this in a very simple environment and it appears that the
> solution is not working.
>

<snip>