1

My application uses jBPM. In jBPM may be long live processes, in processes may exist some variables.

For example, I have a business process of contract approval. When process started, empty contract created. After contract owner fill common properties, financial people fill theirs field, security theirs, lawyers theirs, and so on. In result, this long process finished and whole contract with all data will be saved into db. And all time before contract was only a process variable with id == null (saved at finish).

But in some other processes variables can be saved multiple times in process, not only at end (saved multiple times).

I need to track changes in process entities and use javers for it.

Process entities are hibernate @Entity, and by default javers treat them as Entity object. But id of contract appears only at the end of process. And I get ENTITY_INSTANCE_WITH_NULL_ID.

I try to compare them as ValueObject:

 Javers javers = JaversBuilder.javers()
            .registerValueObject(Contract.class)
            .build()

In some situations properties of my entities are hibernate proxies. It is if entity saved multiple times in process. If I use .withObjectAccessHook(new HibernateUnproxyObjectAccessHook()) it tries to get whole db, object references, references of references and so on. So, it is not working solution.

How to get difference of my object in all cases? When Id is null, and when objects are proxies? And not select all data from db :)

Alex T
  • 2,067
  • 4
  • 20
  • 27
  • I'm not sure what is your question. In Javers Entities must have IDs. If you can't identify your objects you won't be able to track changes in them. – Bartek Walacik Jun 01 '20 at 07:53
  • I want to find diff between 2 objects: old value and new value. I have both instances from jBPM, and need to find dirrerence between these two instances. Why I need have id for it? I need this logic: If all Id's are null - skip them and compare other fields. If one null, other not null, or both not null - show diff. If I change to data objects - then hibernate proxy problem occurs. If I add hibernate unproxy hook - all database retreived by entity references, it's unacceptable. So, how to compare? :) – Alex T Jun 02 '20 at 08:49
  • 1
    well, maybe you should separate your persistence layer (hibernate) from your domain layer? hibernate code and hibernate proxies add really lot of noise to domain objects. but I don't think it's your main issue. In Javers you simply can't have `Entity` without ID. Still, you can compare & commit objects without IDs if and only if you map them as `ValueObjects` – Bartek Walacik Jun 02 '20 at 14:14

0 Answers0