代码如下:但是不能通过编译,请高手指点
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);
}
----------------解决方案--------------------------------------------------------
自定义主键不是写在配置里么,没太看懂lz什么意思。
----------------解决方案--------------------------------------------------------