Looked into different alternatives today. Ran into a stumbling block
right from the get-go in the annotations can't be extended in Java.
Wow, forget little stuff like that fast these days. So I can't just
extend the @Indexed annotations to allow for more than one field.
Plus there is the fact that if I looked at the Spring Neo4j code with
a patient eye I would have noticed that getOrCreateNode operates only
on a particular field in relation to the id property and nothing else
like the actual bean is available once inside the UniqueFactory
getOrCreate method. So I would have needed to consolidate my
composite keys into a single field like Michael suggested in his
"hacky" alternative anyways. Also I learned that copying over the
remaining non-unique properties is done in a separate transaction
inside the SourceStateTransmitter.copyPropertiesTo method. Little
confused here since the LuceneIndex code is the one that takes the
lock so not sure if this will have side-effect for what I am planing
on doing which is....
Exactly what Michael suggested. Inside a TransactionEventHandler I
will consolidate my composite keys into a single field that the
@Indexed is placed on inside the beforeCommit method (gives me access
to all of the nodes). This gives me uniqueness, hopefully.
What I am missing now is a way to integrate "version" optimistic
locking to cancel out overwrites. To that I need access to the
existing node if I am doing an update. Haven't looked carefully but
gut feelings is the old state isn't going to be readily accessible
without a degree of overriding.