注册 登录
编程论坛 J2EE论坛

Hibernate自定义主键问题

wbl313 发布于 2007-11-14 11:07, 881 次点击

代码如下:但是不能通过编译,请高手指点
public class UIDGenerator extends TableGenerator {

private static int idIndex = 1;
private static DecimalFormat df = new DecimalFormat("00");
private static SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssSSS");

public Serializable generate(SessionImplementor arg0, Object arg1)
throws HibernateException {
return nextId();
}

public static synchronized String nextId() {
Date now = new Date();
if (idIndex > 99) idIndex = 1;
// return sdf.format(now)+df.format(idIndex++);
return now.getTime() + df.format(idIndex++);
}

public void configure(Type type, Properties params, Dialect d) {
super.configure(type, params, d);
}

1 回复
#2
黄袖标2007-11-14 17:17
自定义主键不是写在配置里么,没太看懂lz什么意思。
1