Is there any way that when being supported, @PersistenceConstructor annotation will allow the developer to specify what fields should be used for constructor, thus force SDN to always have entities around with specified fields initialized?
I'm talking something like:
Code:
public class MyEntity {
@GraphId
private Long graphId;
private String someNaturalKey;
@PersistenceConstructor
public MyEntity(Long graphId, String someNaturalyKey) {
this.graphId = graphId;
this.someNaturalKey = someNaturalKey;
}
...
Or is this annotation just supposed to use graph ID field?
Although I expected your answer that the policy won't change anytime soon, but as it is now, there are probably 2 ways handling equals/hashCode:
1. Either you use some natural key, and cannot expect that application code will behave correctly in all cases (such as removing element from mapped Set)
2. Or use graph ID as equality field, but then give up from unit tests, and also take care that all your application service methods that work with fresh objects take care to call neo4jTemplate.save(...) immediately after such object has been instantiated
I have tough time seeing plenty of serious applications accepting the terms above.
Don't take my comments offensive, I respect your honest answer, and I am sure that SDN developers did their best when designing this mapping lib (maybe for some reason better couldn't be done, or maybe this is design error in the lib, but then again, we all do them).
Regards,
Vjeran