Antes de mais nada é uma má prática utilizar herança apenas para evitar digitação.
Contudo, fiz um exemplo aqui para funcionar em seu cenário. Ele foi escrito para Hibernate 2.x, portanto provavelmente terá que fazer alguma alteração para trabalhar com Hibernate 3.x.
MyInterceptor.java
public class MyInterceptor implements Interceptor {
private String idUsuario;
public MyInterceptor( String idUsuario ) {
this.idUsuario = idUsuario;
}
/**
* a documentação deste método na interface diz:
* Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for
* the SQL <tt>INSERT</tt> and propagated to the persistent object.
*
* @return <tt>true</tt> if the user modified the <tt>state</tt> in any way.
*/
public boolean onSave( Object entity, Serializable id, Object[] state,
String[] propertyNames, Type[] types ) throws CallbackException {
if( entity instanceof IdData ) {
IdData idData = ( IdData ) entity;
idData.setIdUsuario( idUsuario );
idData.setIdData( new Date() );
return true;
}
return false;
}
public boolean onFlushDirty( Object entity, Serializable id,
Object[] currentState, Object[] previousState,
String[] propertyNames, Type[] types ) throws CallbackException {
return false;
}
public void preFlush( Iterator entities ) throws CallbackException {}
public int[] findDirty( Object arg0, Serializable arg1, Object[] arg2,
Object[] arg3, String[] arg4, Type[] arg5 ) {
return null;
}
public Object instantiate( Class arg0, Serializable arg1 ) throws CallbackException {
return null;
}
public Boolean isUnsaved( Object arg0 ) {
return null;
}
public void onDelete( Object arg0, Serializable arg1, Object[] arg2,
String[] arg3, Type[] arg4 ) throws CallbackException
{}
public boolean onLoad( Object arg0, Serializable arg1, Object[] arg2,
String[] arg3, Type[] arg4 ) throws CallbackException {
return false;
}
public void postFlush( Iterator arg0 ) throws CallbackException {}
}
Para usar adicione o seguinte no local onde instancia a Session:
String idUsuario = // veio de algum lugar
SessionFactory sessionFactory = // veio de algum lugar
Session session = sessionFactory.openSession( new MyInterceptor( idUsuario ) );
Recomendo também a leitura das convenções de código para Java:
http://java.sun.com/docs/codeconv/