|
Hibernate example source code file (UUIDGenerator.java)
The Hibernate UUIDGenerator.java source codepackage org.hibernate.test.annotations.id.sequences; import java.io.Serializable; import java.math.BigInteger; import java.util.UUID; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.id.IdentifierGenerator; /** * Unlike Hibernate's UUID generator. This avoids * meaningless synchronization and has less * than a chance of an asteroid hitting you on the head * even after trillions of rows are inserted. I know * this to be true because it says so in Wikipedia(haha). * http://en.wikipedia.org/wiki/UUID#Random_UUID_probability_of_duplicates * */ public class UUIDGenerator implements IdentifierGenerator { public Serializable generate(SessionImplementor arg0, Object arg1) throws HibernateException { UUID uuid = UUID.randomUUID(); String sud = uuid.toString(); System.out.println("uuid="+uuid); sud = sud.replaceAll("-", ""); BigInteger integer = new BigInteger(sud,16); System.out.println("bi ="+integer.toString() ); return integer; } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate UUIDGenerator.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.