• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Save bug -- Java Client WO 5.2.3 MacOSX
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Save bug -- Java Client WO 5.2.3 MacOSX


  • Subject: Save bug -- Java Client WO 5.2.3 MacOSX
  • From: Luc-Henri Barthélémy <email@hidden>
  • Date: Tue, 16 Nov 2004 14:39:54 +0100

Hello all,
As you know, we have a serious "save" bug with Java Client in WO 5.2.3 and macosx.
I am a new user of Java Client technologies but I used to work with EOF (OBJC) a few years ago, so I trust the NeXT-Apple tools, and I worked seriously to isolate the pb and to find a fix.
I finaly found an acceptable work around waiting for the Apple fix.


I use a non direct to java interface :
1- the pb appears when you insert a new object into a EODisplayGroup with an EODatabase datasource.
2- you can save (an editingContext saveChanges) the new object, the changes are commited to the DB
3- the new object is selected in the displayGroup.
4- if you now changes values in the new selected object and save, you get a client exception (snapshot or firefault exception depending on your relationships) when your client application try to access the object.


After the save the new object referenced into the displaGroup remain a temporary object (with a temporary GlobalId) but you can't refault it without an exception.

The workaround:
Sorry, but the only way I found to repopulate the displayGroup with correct objects is to fetch the displayGroup after the first save, or to send a revertChanges to the editingContext
In our applications this operation is not so heavy, because of the db caches and the app ergonomy (when you add a new row, we don't already have a lot of objects in the related displayGroup).
The problem is more to reselect the new inserted object (this is the current EOF behavior) in the displayGroup after the fetch: the object ID has changed after the fetch, it is now a permanent GID.
I use a trick for that, and I will give you the related java code.
I also use a boolean to perform this specific fetch only when inserting a new row using DG delegate.



Here is the code you can insert into your subclass of EOInterfaceController, or in your generic subclass.


	//
	// class variable
	//
	public boolean inserting;

	protected void connectionWasEstablished()
	{
		super.connectionWasEstablished();
		inserting = false;
		displayGroup().setDelegate(this);
	}

	public void sauve() {
		//
		// avoiding save bug
		//
		// save
		// store the DG current objects into a set
		// fetch the DG
		// store the new DG set
		// select the differences into the 2 sets
		//
		NSSet setAvant;
		NSSet setApres;
		NSSet setDiff;

		this.saveChanges(true,"");
		// or ec.saveChanges();
		//
		// inserting is set in the DG delegate method
		//
		if(inserting)
		{
			inserting = false;
			setAvant = new NSSet(displayGroup().allObjects());
			// dg resynchronize
			this.revertChanges(false);
			// or displayGroup().fetch();
			setApres = new NSSet(displayGroup().allObjects());
			setDiff = setApres.setBySubtractingSet(setAvant);
			// select the diff
			displayGroup().selectObjectsIdenticalTo(setDiff.allObjects());

		}

	}

// delegate method
public void displayGroupDidInsertObject(EODisplayGroup group, Object eo)
{
inserting = true;
}



Luc-Henri Barthélémy Université Paris 5 DSI tél: +33 1 40 46 17 36 mailto:email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: System.out making doubles
  • Next by Date: Re: System.out is repeating the output
  • Previous by thread: message "Failure to contact xserve2.local-1085"
  • Next by thread: XserveHosting.com
  • Index(es):
    • Date
    • Thread