Can not replicate Java 1.4 pattern using Java 5 generics

I am trying to migrate some 1.4 code to Java 5. The code below captures the essence of what I am trying to do. Trouble is I get the following error

Name clash : The method readAll(List<XyzData>) of type Generics has the same erasure as readAll(List<Data>) of type Generics.DAO but does not override it

I sort of understand why it doesn't compile however I am unsure how to fix it, or even if I can use generics in this instance and if I can what is the syntax?

publicabstractclass DAO

{

publicabstractvoid readAll(List<Data> data);

}

publicclass XyxDAO

extends DAO

{

publicvoid readAll(List<XyzData> xyzData)

{

...

}

}

I certainly need to do some more reading about this generics stuff but any help now would be much appreciated.

[1376 byte] By [Yanisa] at [2007-11-26 16:58:34]
# 1

Without a bit more background, it's difficult to be precise, but I would imagine you want something like this (untested):

// Should this be an interface?

public abstract class DAO<T extends Data> {

public abstract void readAll(List<T> data);

}

public class MyDAO extends DAO<MyData> {

public void readAll(List<MyData> myData) {

// ...

}

}

dannyyatesa at 2007-7-8 23:26:21 > top of Java-index,Core,Core APIs...
# 2
It works - that is exactly it. I see now, the <T extends Data> bit is saying that there will be a class that extends Data but we don't know what it is yet. Then in the definition of the class MyDAO we define what T is.ExcellentThanks a lot.
Yanisa at 2007-7-8 23:26:21 > top of Java-index,Core,Core APIs...
# 3
Precisely!
dannyyatesa at 2007-7-8 23:26:21 > top of Java-index,Core,Core APIs...