Index of complex beans in Spring Neo4j

19 views
Skip to first unread message

Matthew Young

unread,
May 11, 2012, 4:45:59 PM5/11/12
to Neo4j
Ashish Dalela took up the question of pushing/pulling complex beans in
Neo4j (his "Nested properties" question)....

I wrote a bit in that question but decided to create a new forum
question with on slightly different angle.  I have the same problem.
 I want to save beans.  The Spring Neo4j is great.  But beans may not
always be unique only off a single or multiple simple properties.
 When I write "simple" I mean simple types.  Beans can have complex
properties (other beans).

For example, let's say I want to represent Software as a Bean and save
it down in Neo4j with Spring Neo4j.  The Software Bean has stuff like
a name and a version and bunch of other simple properties but also an
Organization property that is complex (another bean).  Organizations
are themselves valid candidates a complex beans I want to save in
Neo4j.  Software is unique in my world based on the following
properties:
    Software.name
    Software.version
    Software.Organization.name

where the jump between Software and Organization with be a relation.
 So uniqueness needs to be a conglomeration of different fields.  Not
problem in Lucene.  That is the whole idea of a Document/Field
(multiple) indexing.  And the putIfAbsent methods on the Index
implementation allow me to construct an index which a Value Object
array (made up of the values in my properties regardless where they
come from).  And the key can be whatever I want (like "Software unique
index 1").  This won't be a searchable index only an index used for
locking when creating/updating.

Haven't done an example but in theory this should work.  The
integration with Spring Neo4j is the sticky part.  The @Index
annotation is for a single property.  I want to override/extend the
Index annotation or integrate something else so that save/create
methods of the Neo4jTemplate work off my Index annotation that
populates the Value with my fields.  Ideas?

Thinking about extending the DelegatingGraphDayabasr and overriding
the getOrAndCreate methods with my own UniqueFactory. Thing is that
not sure if this will effect all save and create calls from the
template? The getOrCreate seem to lead back to the EntityPersistor
implementations.
Reply all
Reply to author
Forward
0 new messages