create unique user in application

63 views
Skip to first unread message

Leonardo de Araujo Domingues

unread,
May 13, 2012, 1:10:55 PM5/13/12
to ne...@googlegroups.com
How best to create profiles with unique id? That is, in one application, 
users with UID's there, they should be treated as a primary key in SQL, 
in short, there may be only one user at UID.

Example:

*Create user:
UID: 1
name: Leonard
*Result: OK

*Create user:
UID: 1
name: Bill
*Result: FAILED: User already exists with UID "1"

I'm using the Embedded (neo4j-community - v1.7) in applications Java!

Thanks!

--
Leonardo de Araújo Domingues
Graduando em Sistemas de Informação - UFPB/Campus IV
Laborarório de Aplicação em Vídeo Digital - LAVID/UFPB

Peter Neubauer

unread,
May 14, 2012, 9:48:54 AM5/14/12
to ne...@googlegroups.com
Leonardo,
for this usecase, there is the UniqueFactory for indexes, see
http://api.neo4j.org/current/org/neo4j/graphdb/index/UniqueFactory.html

which is exposed even through REST, see

http://docs.neo4j.org/chunked/snapshot/rest-api-unique-indexes.html

Is that what you are looking for?

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

If you can write, you can code - @coderdojomalmo
If you can sketch, you can use a graph database - @neo4j

Leonardo de Araujo Domingues

unread,
May 14, 2012, 3:41:05 PM5/14/12
to ne...@googlegroups.com
For when the application sends me a UID, just need to verify that the UID already exists in the DBNeo4J,
and if not, will be registered, otherwise I throw an exception.

Anyway, your post will help me a lot because I saw that I need!

Thank you!

2012/5/14 Peter Neubauer <peter.n...@neotechnology.com>

Michael Hunger

unread,
May 14, 2012, 3:55:44 PM5/14/12
to ne...@googlegroups.com
Please use the UniqueFactory as outlined, it uses the index-manager under the hood but does so in a transactional and atomic safe way.

Michael
Reply all
Reply to author
Forward
0 new messages