Hibernate4.3之uuid generate配置方法

 

orm配置 User.hbm.xml


        
            
        ...  

模型User类:

    @Id    
    @Column(unique = true, length = 36, nullable = false)
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "org.hibernate.id.UUIDGenerator")
    public String getId() {
		return id;
	}...

测试Code:


 session = factory.openSession();
        //开启事务
        session.beginTransaction();
			
        User user = new User();
        user.setUsername("test1");
	user.setPassword("11111111");
	user.setCreateTime(new Date());
	user.setExpireTime(new Date());
			
	//提交事务
	session.getTransaction().commit(); 

然后,报Warn:

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


我X,为毛?

难道这个新版本中 GenericGenerator 这个设置没起作用!?

Hibernate版本,4.3.10Final.  数据库 :MariaDB 5.5.28 。



你可能感兴趣的:(java)