-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate GUIDGenerator
PostPosted: Wed Feb 15, 2006 12:48 pm 
Newbie

Joined: Tue Jun 15, 2004 3:52 pm
Posts: 4
Is it possible to use the Hibernate GUIDGenerator class outside any mapping to a database? I'd like to reuse it's unique id generation, but do it with a method call rather than having hibernate doing the generation for me through a mapping. May be a silly question, but I wasn't sure if it was possible or not. Thanks


Top
 Profile  
 
 Post subject: org.hibernate.id.UUIDHexGenerator
PostPosted: Thu Feb 16, 2006 4:46 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Properties props = new Properties();
props.setProperty("separator", "/");
IdentifierGenerator gen = new UUIDHexGenerator();
( (Configurable) gen ).configure(Hibernate.STRING, props, null);
IdentifierGenerator gen2 = new UUIDHexGenerator();
( (Configurable) gen2 ).configure(Hibernate.STRING, props, null);

for ( int i=0; i<10; i++) {
String id = (String) gen.generate(null, null);
System.out.println(id);
String id2 = (String) gen2.generate(null, null);
System.out.println(id2);
}

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.