Reputation: 3631
I'm using MongoRepository for saving/retrieving an object in MongoDB. I have an object with properties defined as such:
@Document
public class ConfigurationItem {
String s1;
@Transient
String s2;
}
The repository will save/retrieve s1 as expected, but leave s2 alone since it's defined transient.
Now the problem: where do I call my "init transients" method which can put the right value into s2? I want this to be called after every instantiation of an object of type ConfigurationItem, but the constructor is too early, s1 does not have its value set yet, and s2's value depends on s1.
Is there a "post construction" method which I can override?
Upvotes: 0
Views: 342
Reputation: 6922
The @PersistenceConstructor annotation should allow you to set s2
based on the value of s1
when the object is hydrated from the database.
Upvotes: 1