Hash java action from communitycommons failing.

3
Hi, I'm having problem with hashing in mendix using the hash java action from the community commons. We have an app that uses mendix 4.4.3 (i know, terrible) and when i use the hash java action it returns different outcomes everytime. I found this topic on the mendix forum: https://community.mendix.com/link/questions/8358 where someone had the same problem. Eric provided the answer ( i noticed that it was the same problem because my hashes also have '[B@78d80b8xx' as outcome), but his answer was 2 years ago and now disappeared from expirebox. So to make a long story short. Could you please help me with editing the java code of the hash action (actually the stringUtils) such that i can get this hashing to work? Thnx in advance
asked
3 answers
4

Albert,
The code of the hash function has been updated in June.
Did you already try that one?

https://github.com/mendix/CommunityCommons/commit/b8a94b3ac6ddfae24bf334b5eb93b693fecaa685

answered
3

Eric Tieniber provided a link to Github which contains corrected code. Did you try that?

answered
2

Hi Albert,

I am assuming that you need hash values to quickly check if two objects are not equal.

If this is the case I would use the standard java 

String - int:hashCode()

Using the Mendix runtime API you can start with the following code:

IMendixObject imo = my_entity.getMendixObject();
int hash = 0;
int mult = 1;
for ( ImendixObjectMember member : 	getMembers(ctx).values() ) {
   hash += mult * member.parseValueToString(ctx).hashCode();
   mult *= 31;
}
return hash;

You might need to correct for references, virtual attributes and system attributes but this is a good starting point.

Hope this helps,

-Andrej

answered