enum as node property

1,251 views
Skip to first unread message

Abdul Azeez Shaik

unread,
May 14, 2012, 5:47:05 AM5/14/12
to ne...@googlegroups.com
Dear all,

If i have to add enum as property to nodes, only way i could think of is, adding new node(for enum type) and create relationship between these two nodes.
Is there any other way of doing it? As per the documentation, i could see that only primitive types are allowed as properties.

Kindly let me know your suggestions for the above use case

Thanks,
 Abdul

Michael Hunger

unread,
May 14, 2012, 5:54:41 AM5/14/12
to ne...@googlegroups.com
I think it depends on your use cases,

your suggestion is a good one if it supports your query use-cases.

Otherwise just storing enum.name() is also a valid approach.

Michael

Abdul Azeez Shaik

unread,
May 14, 2012, 6:02:55 AM5/14/12
to ne...@googlegroups.com
Thanks for the prompt response Michael. You options suits best for my use case.

Thanks again,
Abdul

Abdul Azeez Shaik

unread,
May 14, 2012, 6:22:10 AM5/14/12
to ne...@googlegroups.com
Am using spring data neo4j and using the following code to serialize the string to enum and enum to string. Is there any other standard approach to do this. Am using simple mapping.

enum producttype{
 ENTERPRIZE,
CONSUMER
}
String productty;

set productty(producttype temp) {
        product = temp.name()
}

Kindly let me know if there is any other simple way.

Michael Hunger

unread,
May 14, 2012, 6:29:44 AM5/14/12
to ne...@googlegroups.com

Abdul Azeez Shaik

unread,
May 15, 2012, 3:33:35 AM5/15/12
to ne...@googlegroups.com
Spring-data supports enum and data properties.

Does it support indexing on enum and data properties? I couldn't find out anything on this in documentation.

Michael Hunger

unread,
May 15, 2012, 5:23:53 AM5/15/12
to ne...@googlegroups.com
Right now they are indexed via the current mechanism of neo4j-indexing which calls toString() on the values (which is currently the same for enums).

But this should probably change to index the same values that are stored in the properties. Can you please raise an issue about this at http://spring.neo4j.org/issues

Thanks

Michael
Reply all
Reply to author
Forward
0 new messages