Re: permanentGlobalID not permanent

2014-05-08 Thread Alexander Spohr

Am 08.05.2014 um 05:36 schrieb Jean-François Veillette 
jean_francois_veille...@yahoo.ca:

 Here is the code for the setter:
 
 public void setReference(final ERXGenericRecord ref) {
   EOKeyGlobalID pgid = ref.permanentGlobalID();
   setReferenceGlobalID(ERXKeyGlobalID.globalIDForGID(pgid));

ref.setId(pgid); // this seems to be missing

   // added log to debug ...
   final EOGlobalID gid = editingContext().globalIDForObject(ref);
   log.debug(GlobalID:  + gid + permanent:  + pgid);
 }
 
 give: 
 GlobalID: EOTemporaryGlobalID: 0 0 127 0 0 1 0 0 -5 -116 1 0 0 0 1 69 -39 18 
 -94 -76 -125 18 82 -3permanent: _EOIntegralKeyGlobalID[AGA_Participant 
 (java.lang.Integer)7985]

How should ref know about your pgid?
Where do you set the global id of ref? Something like ref.setId(pgid).
If you don’t set it ref won’t have a global id and therefore must go to the 
database to get one.

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: permanentGlobalID not permanent

2014-05-08 Thread Alexander Spohr
Forget my post. I misunderstood your problem.
Sorry for the noise.

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: permanentGlobalID not permanent

2014-05-08 Thread Ralf Schuchardt
Am 08.05.2014 um 05:36 schrieb Jean-François Veillette 
jean_francois_veille...@yahoo.ca:

 PrimaryKey obtained by permanentGlobalID() are not saved as the primaryKey on 
 saveChanges().
 
 I'm setting a global id as a reference for « soft relationship » (since it 
 point to undefined object) instead of a « hard relationship » (usual when we 
 store the pk).
 
 The problem is that I get 2 primary key (yes 2 sequences number out of the 
 database):
 - the first come from the call to permanentGlobalID(), wich return 7985.
 - the next come from the save of the object itself, it ask again for a 
 sequence.
 Result: the first reference is actually not pointing to the saved object!
 
 
 Here is the code for the setter:
 
 public void setReference(final ERXGenericRecord ref) {
   EOKeyGlobalID pgid = ref.permanentGlobalID();
   setReferenceGlobalID(ERXKeyGlobalID.globalIDForGID(pgid));
   // added log to debug ...
   final EOGlobalID gid = editingContext().globalIDForObject(ref);
   log.debug(GlobalID:  + gid + permanent:  + pgid);
 }
 
 give: 
 GlobalID: EOTemporaryGlobalID: 0 0 127 0 0 1 0 0 -5 -116 1 0 0 0 1 69 -39 18 
 -94 -76 -125 18 82 -3permanent: _EOIntegralKeyGlobalID[AGA_Participant 
 (java.lang.Integer)7985]
 
 It's a wonder project, all EOs (ultimately) inherit from ERXGenericRecord.
 I'm using ERXEC default factory to get editingContext.
 
 From the documentation it says it is supposed to work, so I guess I have 
 something misconfigured.

Do you have a special delegate set in your EODatabaseContext? The stored 
primary key (generated by primaryKeyDictionary called from permanentGlobalID) 
is used by an ERXDatabaseContextDelegate. ERXExtensions.bundleDidLoad normally 
sets an instance of this class as delegate.


Ralf

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: permanentGlobalID not permanent

2014-05-08 Thread Jean-François Veillette
On first sight, it doesn't seem like I set another delegate.
I'll take time to investigate it further in the next few days.

Thanks!

Le 2014-05-08 à 11:06, Ralf Schuchardt r...@gmx.de a écrit :

 Am 08.05.2014 um 05:36 schrieb Jean-François Veillette 
 jean_francois_veille...@yahoo.ca:
 
 PrimaryKey obtained by permanentGlobalID() are not saved as the primaryKey 
 on saveChanges().
 
 I'm setting a global id as a reference for « soft relationship » (since it 
 point to undefined object) instead of a « hard relationship » (usual when we 
 store the pk).
 
 The problem is that I get 2 primary key (yes 2 sequences number out of the 
 database):
 - the first come from the call to permanentGlobalID(), wich return 7985.
 - the next come from the save of the object itself, it ask again for a 
 sequence.
 Result: the first reference is actually not pointing to the saved object!
 
 
 Here is the code for the setter:
 
 public void setReference(final ERXGenericRecord ref) {
  EOKeyGlobalID pgid = ref.permanentGlobalID();
  setReferenceGlobalID(ERXKeyGlobalID.globalIDForGID(pgid));
  // added log to debug ...
  final EOGlobalID gid = editingContext().globalIDForObject(ref);
  log.debug(GlobalID:  + gid + permanent:  + pgid);
 }
 
 give: 
 GlobalID: EOTemporaryGlobalID: 0 0 127 0 0 1 0 0 -5 -116 1 0 0 0 1 69 -39 
 18 -94 -76 -125 18 82 -3permanent: 
 _EOIntegralKeyGlobalID[AGA_Participant (java.lang.Integer)7985]
 
 It's a wonder project, all EOs (ultimately) inherit from ERXGenericRecord.
 I'm using ERXEC default factory to get editingContext.
 
 From the documentation it says it is supposed to work, so I guess I have 
 something misconfigured.
 
 Do you have a special delegate set in your EODatabaseContext? The stored 
 primary key (generated by primaryKeyDictionary called from permanentGlobalID) 
 is used by an ERXDatabaseContextDelegate. ERXExtensions.bundleDidLoad 
 normally sets an instance of this class as delegate.
 
 
 Ralf
 

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: permanentGlobalID not permanent

2014-05-08 Thread Alexis Tual
Hi,

I didn’t know about this permanentGlobalID(), but we use 
primaryKeyInTransaction with success :
http://jenkins.wocommunity.org/job/Wonder/javadoc/er/extensions/eof/ERXGenericRecord.html#primaryKeyInTransaction%28%29
 

Cheers,

Alex

Le 8 mai 2014 à 18:40, Jean-François Veillette 
jean_francois_veille...@yahoo.ca a écrit :

 On first sight, it doesn't seem like I set another delegate.
 I'll take time to investigate it further in the next few days.
 
 Thanks!
 
 Le 2014-05-08 à 11:06, Ralf Schuchardt r...@gmx.de a écrit :
 
 Am 08.05.2014 um 05:36 schrieb Jean-François Veillette 
 jean_francois_veille...@yahoo.ca:
 
 PrimaryKey obtained by permanentGlobalID() are not saved as the primaryKey 
 on saveChanges().
 
 I'm setting a global id as a reference for « soft relationship » (since it 
 point to undefined object) instead of a « hard relationship » (usual when 
 we store the pk).
 
 The problem is that I get 2 primary key (yes 2 sequences number out of the 
 database):
 - the first come from the call to permanentGlobalID(), wich return 7985.
 - the next come from the save of the object itself, it ask again for a 
 sequence.
 Result: the first reference is actually not pointing to the saved object!
 
 
 Here is the code for the setter:
 
 public void setReference(final ERXGenericRecord ref) {
 EOKeyGlobalID pgid = ref.permanentGlobalID();
 setReferenceGlobalID(ERXKeyGlobalID.globalIDForGID(pgid));
 // added log to debug ...
 final EOGlobalID gid = editingContext().globalIDForObject(ref);
 log.debug(GlobalID:  + gid + permanent:  + pgid);
 }
 
 give: 
 GlobalID: EOTemporaryGlobalID: 0 0 127 0 0 1 0 0 -5 -116 1 0 0 0 1 69 -39 
 18 -94 -76 -125 18 82 -3permanent: 
 _EOIntegralKeyGlobalID[AGA_Participant (java.lang.Integer)7985]
 
 It's a wonder project, all EOs (ultimately) inherit from ERXGenericRecord.
 I'm using ERXEC default factory to get editingContext.
 
 From the documentation it says it is supposed to work, so I guess I have 
 something misconfigured.
 
 Do you have a special delegate set in your EODatabaseContext? The stored 
 primary key (generated by primaryKeyDictionary called from 
 permanentGlobalID) is used by an ERXDatabaseContextDelegate. 
 ERXExtensions.bundleDidLoad normally sets an instance of this class as 
 delegate.
 
 
 Ralf
 
 
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/webobjects-dev/alexis.tual%40gmail.com
 
 This email sent to alexis.t...@gmail.com

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

permanentGlobalID not permanent

2014-05-07 Thread Jean-François Veillette
PrimaryKey obtained by permanentGlobalID() are not saved as the primaryKey on 
saveChanges().

I'm setting a global id as a reference for « soft relationship » (since it 
point to undefined object) instead of a « hard relationship » (usual when we 
store the pk).

The problem is that I get 2 primary key (yes 2 sequences number out of the 
database):
- the first come from the call to permanentGlobalID(), wich return 7985.
- the next come from the save of the object itself, it ask again for a sequence.
Result: the first reference is actually not pointing to the saved object!


Here is the code for the setter:

public void setReference(final ERXGenericRecord ref) {
EOKeyGlobalID pgid = ref.permanentGlobalID();
setReferenceGlobalID(ERXKeyGlobalID.globalIDForGID(pgid));
// added log to debug ...
final EOGlobalID gid = editingContext().globalIDForObject(ref);
log.debug(GlobalID:  + gid + permanent:  + pgid);
}

give: 
GlobalID: EOTemporaryGlobalID: 0 0 127 0 0 1 0 0 -5 -116 1 0 0 0 1 69 -39 18 
-94 -76 -125 18 82 -3permanent: _EOIntegralKeyGlobalID[AGA_Participant 
(java.lang.Integer)7985]

It's a wonder project, all EOs (ultimately) inherit from ERXGenericRecord.
I'm using ERXEC default factory to get editingContext.

From the documentation it says it is supposed to work, so I guess I have 
something misconfigured.

But from debuging the code it doesn't look at all like it's supossed to work!
When deep inside the saveChanges(),  it simply call toBeSavedEO.__globalID() 
which still return the temporaryGlobalID instead of the permanent one.
To illustrate here is a patch that make it work:
$ git diff Sources/
diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEC.java 
b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEC.java
index fde6607..99fe0c0 100644
--- a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEC.java
+++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEC.java
@@ -931,6 +931,12 @@ public class ERXEC extends EOEditingContext {
   public EOGlobalID globalIDForObject(EOEnterpriseObject 
eoenterpriseobject) {
   boolean wasAutoLocked = autoLock(globalIDForObject);
   try {
+   if (eoenterpriseobject instanceof ERXGenericRecord) {
+   ERXGenericRecord ereo = 
(ERXGenericRecord)eoenterpriseobject;
+   if (ereo._permanentGlobalID != null) {
+   return ereo._permanentGlobalID;
+   }
+   }
   return super.globalIDForObject(eoenterpriseobject);
   }
   finally {
diff --git 
a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXGenericRecord.java 
b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXGenericRecord.java
index 8c11ada..da21610 100644
--- 
a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXGenericRecord.java
+++ 
b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXGenericRecord.java
@@ -904,8 +904,8 @@ public class ERXGenericRecord extends EOGenericRecord 
implements ERXGuardedObjec
   }
   return freshObject;
   }
-   
-   private EOKeyGlobalID _permanentGlobalID;
+
+   EOKeyGlobalID _permanentGlobalID;

   /**
* This method allows you to compute what the permanent EOGlobalID will 
be




What am I missing??? (presuming it's a configuration issue and not a bug)

Thanks,

--
jfv

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com