databaseManager.recalcualte(record) in HC, calcs in module

The forum to discuss the Headless version of Servoy. Web, Java and Servlet development questions can all be posted here.

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby Robert Huber » Fri Dec 31, 2010 10:25 pm

jcompagner wrote:we are talking here about stored calcs.. unstored cacls shouldn't have any problems and are way faster and easier to use


I'm not sooo sure about that.

jcompagner wrote:The good thing is that if you dont rely on the stored calc with queries or aggregates it doesn't matter, because then it is just an UI thing and at the moment a user will display that order it will be updated.


You just forget that there are in some applications quite a lot of reports and statistics, and then it's NOT a HI thing, but a serious problem!

Regards,
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby jbader » Sat Jan 01, 2011 1:12 am

So do ours, but nobody believes it because it is not handily reproducable in a complex solution where you often just can't make a sample in a useful time (paid by who?).


Actually over the years this have become a major sore point for me. I fee like if I can't reproduce an issue in a simple, concise and convenient sample solution then I don't get support. Sample solutions are a major time sink, and seeing as this is a *commercial* RAD tool, with the "R" of course standing for "Rapid" then if I spend all my time building sample solutions that attempt to reproduce issues that no one acknowledges otherwise, the tool loses value quickly. But this of course is a topic for another post.

Johan, you certainly know more than anyone about under what circumstances calcs do and do not work/fire/run updates etc then anyone else. I have provided my use case, and I really need some help understanding where the problem is. [please]
jbader
 
Posts: 520
Joined: Sun Sep 18, 2005 4:24 am
Location: Miami, FL

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby Robert Huber » Sat Jan 01, 2011 2:20 am

jbader wrote:Actually over the years this have become a major sore point for me. I fee like if I can't reproduce an issue in a simple, concise and convenient sample solution then I don't get support. Sample solutions are a major time sink, and seeing as this is a *commercial* RAD tool, with the "R" of course standing for "Rapid" then if I spend all my time building sample solutions that attempt to reproduce issues that no one acknowledges otherwise, the tool loses value quickly. But this of course is a topic for another post.


Jeff, you express what we have found (over the years) as well.

Regards,
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby pbakker » Mon Jan 03, 2011 12:04 pm

Hi Jeff (and others),

Rereading this entire thread, which got hijacked somewhere along the way, I read that you would create a simple sample. Did you ever do this? Also, which version of Servoy are you using (asked by Johan, no answer yet). This is important to us.

As for getting support/the time sink creating sample solutions: we do our best trying to reproduce reported issues, but as there can be many factors that play a role, we cannot always reproduce the reported behavior. Therefor, unfortunately, we rely on the person reporting the issue to make a reproducable case.

As for the red flag: up to a certain point I agree with David: when I see a databaseManager.recalculate(...) in code, I wonder what is wrong, because it shouldn't be necessary to perform recalculations, except for stored calculations and then only in the following scenario: if you require stored values in the database to be the correct value for external access (reporting tools for example) or when you extract their values from the database through databaseManager.getDatasetByQuery(...).

Why? Because in all other scenario's, as soon as Servoy loads a record, the calcs of the record will recalculate themselves and from the moment onwards that they will keep themselves up to date until the record gets unloaded. When a calc gets fired, it "records" which data is accessed in the calculation up to the point where a value is returned in the calc code. From that moment onwards, the calc "listens" to changes made to the data the previous calculation was dependant on.

So, as long as you are just within a Servoy Client and you don't show the values of stored calculations using a getDatasetByQuery(...), there is no reason to call databaseManager.recalculate().

The databaseManager.recalculate(...) function is basically just a convenient function to loop over an entire foundset (containing more records that initially cached in the FoundSet), touching each record, which triggers all the stored calcs which update themselves in the database if required.

If you're in the situation where external insert/updates/deletes occur on data used by Servoy, you shouldn't call recalculate, but call refreshRecordFromDatabase() (or plugins.rawSQL.flushAllClientsCache(...) depending on how far you want to take it). Off course it would be even better to get that external process to notify Servoy of the dataChange, but that is another story.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby jcompagner » Mon Jan 03, 2011 12:35 pm

Robert Huber wrote:
jcompagner wrote:The good thing is that if you dont rely on the stored calc with queries or aggregates it doesn't matter, because then it is just an UI thing and at the moment a user will display that order it will be updated.


You just forget that there are in some applications quite a lot of reports and statistics, and then it's NOT a HI thing, but a serious problem!


i didn't forget that, i did mention that " if you dont rely on the stored calc with queries or aggregates"

so yes if you do that then you need to have calcs up to date.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby jcompagner » Mon Jan 03, 2011 12:40 pm

jbader wrote:Johan, you certainly know more than anyone about under what circumstances calcs do and do not work/fire/run updates etc then anyone else. I have provided my use case, and I really need some help understanding where the problem is. [please]


jeff, you really need and i do stress this, you need to go to 5.2.4
Because you use db transactions and columns with default values, there where problems with that in 5.2.2 and lower when columns with default values didn't update related foundsets (what you also reported in another thread)
that was fixed in 5.2.3 but then default values and db transactions but surfaced this is fixed in 5.2.4.
So in your case you really need to be on 5.2.4

These 2 things don't really have to do anything specific with calcs. Stored calcs are just column values that are changed and updated to the database when coming to storing it to the database (there is no difference in that way)

Then calcs just should work, besides the cases that paul and i described in this thread.
databaseManager.recalculate() should really always update the stored column values of the records that are walked over. I don't know any way in 5.2.4 why that would not work for you.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby Robert Huber » Mon Jan 03, 2011 1:09 pm

I am glad you noticed it, just didn't interpret your line correctly :D
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby ryanparrish » Mon Jan 03, 2011 4:15 pm

Johan and Paul,

Jeff and I are using version 5.2.2 -build 1002, we tried 5.2.3 when it came out but all the regressions meant we had to roll back to 5.2.2 and subsequently hold off on 5.2.4 until we have the time to really test it well.

To answer both Paul and Johan, yes the reason we do use recalculate() is because of exactly both of those three situations (external reports, .getDatasetByQuery(), aggregates). We utilize jasper reports (and soon jasper server) quite heavily here and rely on queries embedded within the report, and their sub-reports. Also, we never insert or update data outside the servoy data model, we went down that trap filled road in the previous version of our software and vowed to keep everything 'pure' servoy in this version. Also keep in mind that I previously said that our solution does have an application.output() right after the recalc in HC and the data that is logged is correct, it just doesn't ever get written to the database when it is done within a HC batch job.

I think the main questions Jeff really wants to know is this...
*Does there exist unit tests at Servoy for things like verifying stored calcs work the same in smart client and HC?
*Are there unit tests to make sure stored calcs based on aggregates work the same in smart client and HC?
*Are there unit tests to make sure stored calcs work the same when called within a transaction, not within a transaction, with .autoSave() set to true or false (making the assumption that the user knows what they are doing and is calling things in the sequence and syntax).
*Are there unit tests to make sure auto enter DP's that are defined by the database execute correctly inside and outside a transaction?
*And are these unit tests run with each release?

We totally understand the nature of trying to debug someone else's code via snippets on a forum and the reasoning behind the request for sample solutions, we are programmers also here. But as everyone else here I'm sure can attest, bugs and feature requests don't stop coming from users during the weeks that you need to spend to build out a near duplicate of your entire code base to demonstrate the specific behavior deep within your solution that is being seen. So we would really like to know if the servoy methods and features are always tested to verify correct functionality prior to release, as a sanity check on our own side. We are fine if everything is broken because we are messing up, we just need to know for sure that the tools we rely on are performing as we expect them to with every release (that auto enter within a txn bug seemed like a major oversight to us, as a programer that didn't come from the 4GL world I can't imagine doing things any other way).
ryanparrish
 
Posts: 162
Joined: Thu May 17, 2007 7:49 pm
Location: Miami, FL

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby jcompagner » Mon Jan 03, 2011 4:33 pm

the code for calcs is exactly the same for smart or headless client
the calculation engine, row manager,foundsets thats all the same code there is no difference in that
Client changes are in the UI itself and the interaction with the UI.

But calling databaseManager.recalculate(foundsetOrRecord) touches the exact same code for any client that we have in Servoy.

then if the stored calc is recalculated (so if that is triggered) then there is no change what so ever if that where a normal column.. Then it is just a column change that will get saved to the database.

We have all kinds of test, but there are many many combinations. And yes some will be slipped through. For example some of the test can only be tested with 2 clients and then it is not really a unit test anymore (its to big)
All our unit test are run after any check in.

But you guys really must go to 5.2.4, you use a combination of "settings" that only work correctly in 5.2.4
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby ryanparrish » Mon Jan 03, 2011 5:59 pm

jcompagner wrote:the code for calcs is exactly the same for smart or headless client
the calculation engine, row manager,foundsets thats all the same code there is no difference in that
Client changes are in the UI itself and the interaction with the UI.

But calling databaseManager.recalculate(foundsetOrRecord) touches the exact same code for any client that we have in Servoy.


That I know, I've looked at the code quite a bit now that it's open. But one programer to another we both know we often use the answer "things are exactly the same, they should work the same" only to find something that we didn't think of in the way it's called or combinations of the object state that really isn't the same that is causing the apparent issue.

jcompagner wrote:But you guys really must go to 5.2.4, you use a combination of "settings" that only work correctly in 5.2.4

If that's the case then it is something we are going to work towards now, and hope that it solves our long standing issue.
ryanparrish
 
Posts: 162
Joined: Thu May 17, 2007 7:49 pm
Location: Miami, FL

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby jbader » Mon Jan 03, 2011 6:13 pm

But you guys really must go to 5.2.4, you use a combination of "settings" that only work correctly in 5.2.4


Johan,

Can you be specific? What combination of settings is this exactly and why is it that if something is broken in 5.2.2 that is not documented anywhere. Banging away on a forum post for a month to find out there is indeed some unknown problem with calculations, that I would have never otherwise discovered without asking is pretty frustrating.

Please tell me what is broken in 5.2.2.

Thanks a lot and happy new year
jbader
 
Posts: 520
Joined: Sun Sep 18, 2005 4:24 am
Location: Miami, FL

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby jcompagner » Mon Jan 03, 2011 6:57 pm

this is for you broken in 5.2.2:

viewtopic.php?f=5&t=14943&p=81747#p79693

that is because you use db default column values, then it could be that when you update a column X on a record then you don't see that change in your related foundset.
The databroadcast was not working in this situation. So this could also result in you not seeing calc updates when you think the data is changed.. (in another client)

This is fixed in 5.2.4

This fix doesn't directly have anything to do with calcs (that could just be a side effect)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby jbader » Mon Jan 03, 2011 7:12 pm

But what does broadcasting have to do with our calcs not being written to the database? Do you see some connection that I am missing?

You think that by updating to 5.2.4 that our calcs will be written to the DB and our databroadcasting issues will go away?
jbader
 
Posts: 520
Joined: Sun Sep 18, 2005 4:24 am
Location: Miami, FL

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby jcompagner » Mon Jan 03, 2011 8:45 pm

i dont know exactly what goes wrong for you, but you use default column values and transactions, both that had some changes in the 2 releases that where done after the release you use.

again if the calc code is called and you return a different value then before, then it has nothing to do with being a calc. then it is exactly the same as you just did record.value = x
because the stored calc's value is exactly the the same as a normal record value.
So if you are sure about that the calc is called, then we just have to look why the insert statement doesnt happen (for in mem transactions when you call saveData(true) and directly when you only use db transactions)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: databaseManager.recalcualte(record) in HC, calcs in module

Postby jbader » Mon Jan 03, 2011 8:50 pm

if you are sure about that the calc is called, then we just have to look why the insert statement doesnt happen (for in mem transactions when you call saveData(true) and directly when you only use db transactions)


Meaning you/your team are going to look into testing updates/inserts of records with stored calcs when the table has auto enter DB managed data, when in a transaction? Or meaning you need me to do something further?

Please advise!
jbader
 
Posts: 520
Joined: Sun Sep 18, 2005 4:24 am
Location: Miami, FL

PreviousNext

Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 3 guests