If you have two objects a and b in the same DataContext, then you can check to see if they refer to the same database entity as simply as this:

{{ if (a == b) }}

If the objects are not in the same DataContext then this will not be true.

To compare objects in separate contexts, then you can compare the object ids.

{{ if (a.getObjectId().equals(b.getObjectId()) }}