Using org.hibernate.id.UUIDHexGenerator which does not generate IETF RFC 4122 compliant UUID values;

项目部署,启动过程中有以下警告:

[WARN]: Using org.hibernate.id.UUIDHexGenerator which does not generate IETF RFC 4122 compliant UUID values; consider using org.hibernate.id.UUIDGenerator instead

查看项目中用户类的主键生成策略:

 

[java] 
view plain
 copy  

  1. @GenericGenerator(name = “system-uuid”, strategy = “uuid.hex”)  
  2. @Id  
  3. @GeneratedValue(generator = “system-uuid”)  
  4. @Column(name = “user_id”)  
  5.   
  6. public String getUserId() {   
  7.     return userId ;  
  8. }  

经查询,Hibernate 3.6开始,如果有model的主键有uuid生成,就会报这个错误,采用最新的生成策略,改成下面的就会正常

 

 

[java] 
view plain
 copy  

  1. @Id  
  2.     @Column(length = 32, nullable = false)  
  3.     @GeneratedValue(generator = “uuid2” )   //指定生成器名称  
  4.     @GenericGenerator(name = “uuid2”, strategy = “org.hibernate.id.UUIDGenerator” )  //生成器名称,uuid生成类  

 

XML配置:

原来的:

 

[html] 
view plain
 copy  

  1. <id name=“id” type=“string”>  
  2.        <column name=“ID” length=“32” />  
  3.        <generator class=“uuid” />  
  4.    </id>  

 

现在改变后的:

[html] 
view plain
 copy  

  1. <id name=“id” type=“string”>  
  2.             <column name=“ID” length=“36” />  
  3.             <generator class=“uuid2” />  
  4.         </id>  
    原文作者:GordonDicaprio
    原文地址: https://www.cnblogs.com/hfultrastrong/p/7799622.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞