Hey,

I currently resolve circulare dependencies with JsonIdentityInfo and new 
generated UUID. I would like use existing primary key. My problem is that 
my PK is a composite key of normally two attributes (String or int) "id" 
and "version". I cannot change the classes because of 3rd party lib. I can 
only use Mixin or something else.

public class Parent {
  // this is my identiy composite key
  ParentPK pk;
  String bez;
  Date created;
  Child child;

  // constructor, getter and setter
}

public class ParentPK {
  int parentId;
  int version;

  // constructor, getter and setter
}

public class Child {
  String childId;
  Parent parent;

  // constructor, getter and setter
}

How can I use my ParentPK as identity in Jackson? I've tried to use 
JsonIdentityInfo in combination with virtual attributes and JsonAppend. But 
his won't work because the property does not exist in POJO. In my mind I've 
several ideas as solutions but don't know whether they can implemented in 
Jackson:

   - Use existing ParentPK JSON representation e.g. {id:"99", version:"v1"} 
   as JsonIdentityInfo and use equals method in Jackson to compare objects 
   will be the best because no additional attribute will be added to parent. 
   But I don't know whether custom objects are possible as identity?
   - Create virtual String attribute "compositeKey" e.g. "99-v1 and use it 
   as JsonIdentityInfo. But the virtual attribute via JsonAppend cannot be 
   used in combination with JsonIdentityInfo.


Have anyone an idea to implement this?

Thx
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/a76a6b48-91bc-416c-ba52-0c721980bff5%40googlegroups.com.

Reply via email to