Alas not because if EOUtilities.rawRowsForSQL is not called, it works. 
Otherwise not.

It's perfectly reproducible without any change at the database level.

Thanks for trying ;-)

Philippe

On 5 sept. 2011, at 18:58, Cheong Hee Ng wrote:

> Could it be that the NO_Sent_Notification_Request_
> Log_TEST is a new table that you have created lately and that your 
> EO_PK_TABLE could not locate it for primary key.   Just curious. 
> 
> 
> 
> On Mon, Sep 5, 2011 at 8:17 PM, Philippe Rabier <[email protected]> wrote:
> I don't want to bug the list too much because I can deal easily with this 
> issue. 
> 
> However my curiosity would be happy if someone knows the reason. 
> 
> That's said, Cheong, I doubt the cause are those you think for 2 reasons:
> - informations inserted in raw SQL are not fetched as EO, never (they are 
> used for statistics in another WO app) and  I pass a new fresh EC to 
> EOUtilities.raw...
> 
> -  NONotificationRequestLog   object is also new, inserted also in a new EC 
> as showed in the code. 
> 
> So I can't invalidate any object because one is not known by EOF and the 
> other one is just created. 
> 
> I made another test: I put the raw insert command in the same method as below 
> using only one EC and I get the same issue: exception when EOF tries to get a 
> primary key. So I'm pretty sure that the insert command causes the exception 
> when I call saveChanges
> 
> Philippe
> 
> Sent from my iPhone
> 
> On 5 sept. 2011, at 12:18, "Cheong Hee (Gmail)" <[email protected]> wrote:
> 
>> Hi Philippe
>>  
>> I think somehow 'NO_Sent_Notification_Request_Log_TEST' is already 
>> registered as an existing object in your ec.  This caused the ec to fetch 
>> the object again and therefore failed and aborted.  I may be just reiterated 
>> your point to be sure : )
>> Just to test, you may need to invalidate all objects in the ec and try to 
>> save the log object again.
>>  
>> Cheers
>>  
>> Cheong Hee
>>  
>>  
>> ----- Original Message -----
>> From: Philippe Rabier
>> To: Ray Kiddy
>> Cc: WebObjects (Group)
>> Sent: Monday, September 05, 2011 4:55 PM
>> Subject: Re: Feedback about issue with MySQL and get primary key
>> 
>> Hi Ray,
>> 
>> Thank you for the tip. That's something interesting to change the sql 
>> expression on the fly. I was looking for that too.
>> 
>> But you don't get me so I gonna try to be explain with more concise 
>> explanations.
>> 
>> The algorithm is the following:
>> 1 - get data from the DA, check data and return a result (basically 2 
>> results : data accepted or not)
>> 2 - if result = data_accepted, I insert new data using raw sql
>> 3 - write into a log entity (in any circumstances) using EOF aka create an 
>> object and insert it into an ec.
>> 
>> What I tried to explain is that when the EOUtilities.rawRowsForSQL is 
>> executed in step 2 (and it works, I don't have any issue here), the step 3 
>> fails because he can't get a primary key. If the step 2 is not executed, the 
>> step 3 is executed successfully.
>> 
>> I put the simple code below that is executed, just in case but nothing weird 
>> I guess (I removed the try/catch).
>> 
>> Cheers,
>> 
>> Philippe
>> 
>> String aIpAdress = (String) 
>> userInfo.get(NotificationUserInfoEnum.IP_ADDRESS.toString());
>> String aRequest = notificationData.getSenderUri();
>> String aStatus = (String) 
>> userInfo.get(NotificationUserInfoEnum.STATUS.toString());
>> 
>> EOEditingContext ec = ERXEC.newEditingContext();
>> ec.lock();
>> NOApplication anApplication = null;
>> if (notificationData.getApplicationName() != null)
>> anApplication = NBCacheManager.getInstance().application(ec, 
>> notificationData.getApplicationName(), notificationData.getPlatform());
>> 
>> NONotificationRequestLog notificationLog = 
>> NONotificationRequestLog.createAndInsertNONotificationRequestLog(ec);
>> 
>> if (anApplication!=null)
>> {
>> notificationLog.setApplication(anApplication);
>> notificationLog.setApplicationName(anApplication.name());
>> }
>> else if (notificationData.getApplicationName() != null)
>> notificationLog.setApplicationName(notificationData.getApplicationName());
>> 
>> //If a notification is received, we don't know the platform
>> if (!(this instanceof NBNotificationReceivedRecorder))
>> notificationLog.setPlatform(notificationData.getPlatform());
>> notificationLog.setIpAddress(aIpAdress);
>> notificationLog.setRequest(aRequest);
>> notificationLog.setStatus(aStatus);
>> 
>> ec.saveChanges();
>> 
>> 
>> 
>> On 5 sept. 2011, at 01:08, Ray Kiddy wrote:
>> 
>>> 
>>> Your rawRowsForSql call through an exception because you are completely 
>>> bypassing the primary key generation process, so it you want to insert rows 
>>> using this call, you need to generate the primary keys yourself.
>>> 
>>> There is a better way to do this. See below.
>>> 
>>> - ray
>>> 
>>> On Sep 4, 2011, at 7:49 AM, Philippe Rabier wrote:
>>> 
>>>> Hi all,
>>>> 
>>>> Not a question but a feedback if you have the same issue but I don't have 
>>>> explanation and I didn't look for any.
>>>> 
>>>> Env: 
>>>> WO 5.4.3, java 6 on Mac OS X 10.6.7, Eclipse 3.4, Wonder a bit old 
>>>> (several months), MySQL v5.0.88
>>>> 
>>>> Context: 
>>>> DA where informations are checked, fetched then if everything is fine, 
>>>> informations are saved. At the end, we write into a log the request plus 
>>>> the result and some informations (IP address, …).
>>>> 
>>>> When informations are saved, I decided to use EOUtilities.rawRowsForSQL to 
>>>> execute an insert sql command in order to optimize the complete R-R.
>>>> 
>>>> Then I write into the log the request, result, … as I said.
>>>> 
>>>> If the insert command is executed, when the log is saved (through its 
>>>> editingContext), I got an exception when the adaptor tries to get a new 
>>>> primary key:
>>>> 
>>>> Sep 04 14:52:56 YNP_NOWebServicesApp[5000] DEBUG NSLog  - Searching for 
>>>> primary key value for NO_Sent_Notification_Request_Log_TEST
>>>> Sep 04 14:52:56 YNP_NOWebServicesApp[5000] DEBUG NSLog  -  
>>>> evaluateExpression: 
>>>> <com.webobjects.jdbcadaptor._MySQLPlugIn$MySQLExpression: "SELECT PK FROM 
>>>> EO_PK_TABLE WHERE NAME = 'NO_Sent_Notification_Request_Log_TEST' FOR 
>>>> UPDATE" withBindings: >
>>>> Sep 04 14:52:56 YNP_NOWebServicesApp[5000] INFO  
>>>> er.extensions.ERXAdaptorChannelDelegate.sqlLogging  - "Unknown"@795485135 
>>>> expression took 232 ms: SELECT PK FROM EO_PK_TABLE WHERE NAME = 
>>>> 'NO_Sent_Notification_Request_Log_TEST' FOR UPDATE
>>>> Sep 04 14:52:56 YNP_NOWebServicesApp[5000] DEBUG NSLog  - fetch canceled
>>>> Sep 04 14:52:56 YNP_NOWebServicesApp[5000] DEBUG NSLog  - 0 row(s) 
>>>> processed
>>>> Sep 04 14:52:56 YNP_NOWebServicesApp[5000] INFO  
>>>> er.transaction.adaptor.Exceptions  - Database Exception occured: 
>>>> java.lang.IllegalArgumentException: Array is empty
>>>> 
>>>> If I replace EOUtilities.rawRowsForSQL  with 
>>>> ERXEOAccessUtilities.insertRow(ec, 
>>>> NOAppOpenedAfterPushEvent.Keys.ENTITY_NAME, dic), everything works great.
>>>> 
>>>> For those who were wondering why I wanted to use 
>>>> EOUtilities.rawRowsForSQL(), the reason is that I wanted to use "INSERT 
>>>> DELAYED INTO ".
>>>> 
>>>> Have a good sunday.
>>>> 
>>>> Philippe
>>> 
>>> 
>>> 
>>> I used to know how to do this using only WebObjects classes, but I cannot 
>>> remember any longer. But this works with Wonder classes. There may be a 
>>> better way to get to the EOAdaptorChannel.Delegate, but I always seem to 
>>> re-find the chain one has to follow. You can get the EODatabaseContext at 
>>> any point that you have an eo and use that to get the EOAdaptorChannel. 
>>> Once you have them, you do not need to find them again. In the code below, 
>>> the setDelegate methods end up getting called more often than they need to 
>>> be, but since I am using singletons for the delegate instances, this is 
>>> harmless. I ran this and verified, after turning on the 
>>> EOAdaptorDebugEnabled flag, I get:
>>> 
>>> Sep 04 15:07:54 TreeFul[51162] DEBUG NSLog  -  evaluateExpression: 
>>> <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "INSERT DELAYED 
>>> INTO c_tree_closure(down, up, distance) VALUES (?, ?, ?)" withBindings: 
>>> 1:39(down), 2:39(up), 3:0(distance)>
>>> eosqlexpression statement: INSERT DELAYED INTO c_tree_closure(down, up, 
>>> distance) VALUES (?, ?, ?)
>>> Sep 04 15:07:54 TreeFul[51162] DEBUG NSLog  -  evaluateExpression: 
>>> <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "INSERT DELAYED 
>>> INTO c_tree_closure(down, up, distance) VALUES (?, ?, ?)" withBindings: 
>>> 1:39(down), 2:1(up), 3:1(distance)>
>>> 
>>> So, it does work. Anyway, good luck.
>>> 
>>> cheers - ray
>>> 
>> 
>> 
>> 
>> _______________________________________________
>> 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/chng34%40gmail.com
>> 
>> This email sent to [email protected]
> 

 _______________________________________________
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]

Reply via email to