neo4j / sdn-rx

Nextgen Spring Data module for Neo4j supporting (not only) reactive data access and immutable support
https://neo4j.github.io/sdn-rx
Apache License 2.0
65 stars 23 forks source link

dynamic properties #213

Closed sergeily closed 4 years ago

sergeily commented 4 years ago

it would be great to have dynamic-properties option such as OGM annotation @Properties

ogm-manual

meistermeier commented 4 years ago

(Sorry for the repetition of my comment on #214) Could you give an example for an use-case? In general it might make more sense to create a relationship to another node holding those informations. Dynamic properties are just a unsorted set of informations that somehow work around the idea of object mapping.

sergeily commented 4 years ago

Hi,

For each node we have explicit properties and auxiliary properties and we prefer to store these auxiliary properties as a separate collection.

When we use SDN+OGM it's possible to configure entity like


@NodeEntity(label="Column")
public class DaeColumnNode extends DaeNode {
    ......
    private String name;
    ......
    @Properties(prefix = "properties", allowCast = true)
    private Map<String, Object> properties;
    ......
}

And when we save node to neo4j Map<String, Object> would be save with prefix

name: columnNode2
properties.port: 8080
properties.timeZone: America/New_York
michael-simons commented 4 years ago

Hi.

That's a feature a lot of people like, actually. We are not against it either. Currently there seems to be work to have some similar in Spring Data commons. We will discuss this with Pivotal / VMWare.

Thank you!

michael-simons commented 4 years ago

We have been thinking about having something more similar to @Embedded to have those properties in a domain specific, structured way. That would also remove the need for a context to see what properties are in the database and which are in the domain to keep them in sync.

haris-zynka commented 4 years ago

This is quite good. I have stuff that needs translation, and I tried Map<String,String> to have something like

{
  "en": "Stuff",
  "sv": "Objekt"
}

but it didn't work and as a temp workaround I added

data class LangThing (val en: String, val sv: String)

However, you can see the limitation of supporting every language would mean manually writing each field. There's some more stuff which I'd like dynamic as I take it as JSON from other servers and don't care about them just show them to the user.

Now I realised that you guys use Map<String,Object> for dynamic relationships If you use something as suggested @Embedded then:

  1. It's more semantic, developer actually knows that's an embedded document with dynamic properties and it's hard to confuse it with anything else - not having any annotation I guess could lead to unwanted results at some points and storing stuff mistakenly
  2. It clears out stuff when having dynamic embedded object and dynamic relationship

I suggest maybe @EmbeddedNode or @EmbeddedObject as I think I saw some @Embedded annotations before used by other frameworks in Java or I might be mistaking.

meistermeier commented 4 years ago

Since we are in a migration process to the original Spring Data Neo4j and have to archive this repository, the issue also go migrated to: https://jira.spring.io/browse/DATAGRAPH-1347 Please watch or comment on the issue in Jira for further communication.