Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jnosql-dev] Creates a @UniqueName in Graph API

Currently, the Graph integrates with Tinkerpop, and that has Id whose some implementation does not allow a defined Id, so:

Guest hillmer = Guest.of("Hillmer");
hillmer = graphTemplate.insert(hillmer);

Guest hillmer2 = Guest.of("Hillmer");
hillmer2 = graphTemplate.insert(hillmer2);

Guest hillmer3 = Guest.of("Hillmer");
hillmer3 = graphTemplate.insert(hillmer3);

Inspired by NaturalId from hibernate the goal is create a UniqueName.

So,

@Entity
public class Guest {
@Id
private Long id;

@UniqueVertexProperty
@Column
private String name;
}

So:

Guest hillmer = Guest.of("Hillmer");
hillmer = graphTemplate.insert(hillmer);

Guest hillmer2 = Guest.of("Hillmer");
hillmer2 = graphTemplate.insert(hillmer2);// an exception because cannot insert twice



Ref: https://github.com/eclipse/jnosql-artemis/issues/42

--
Otávio Gonçalves de Santana

Back to the top