Result mapping and generic fields

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Result mapping and generic fields

Hi Everyone,

Long time iBATIS user starting a new project with mybatis -- woohoo!
I have a base Entity class along the lines of:

abstract class Entity<PK extends Serializable> {

  private PK id;

  public setId(PK id) { = id; }
  public PK getId() { return id; }


PK will typically be a Long.  If I create a result map for this field
the value always ends up null even though it is being returned as part
of the query.  If I make the field non-generic, i.e., a Long, then the
mapping works fine.  Is it possible to map this field and have the
field be generic or am I breaking some fundamental rule?