I have a mentor type character who gives me projects to do on a regular basis... and then messages me asking for it. My next assignment then was to do setup Hibernate and be able to do CRUD on an object.
I had a couple of problems getting going related to my box itself. For whatever reason, it takes ages to unzip files. I needed Ant, HSQL DB and the hibernate jar files... and it took painfully long.
I've been working for a while on a simple example based on the Hibernate Reference Documentation but I've run into an issue with the List, eclipse seems to choke on it. I get an error that says:
The List it mentions is from
My JDK in case anyone is wondering is 1.6.
I had a couple of problems getting going related to my box itself. For whatever reason, it takes ages to unzip files. I needed Ant, HSQL DB and the hibernate jar files... and it took painfully long.
I've been working for a while on a simple example based on the Hibernate Reference Documentation but I've run into an issue with the List, eclipse seems to choke on it. I get an error that says:
List is a raw type. Reference to generic type List <E> should be parameterized
import java.util.List;The line in question is:
List stuff = psm.listPersistedStuff();and the function declaration is:
private List listPersistedStuff()I think some post Java 5 generics stuff is getting in the way. I've never used generics before and I guess I'll be learning quickly :). But if anyone knows what's wrong here, I would appreciate a pointer or two. Some of the Sun forums talk about suppressing the warnings in the function, but they also suggest that is a poor way to get around the problem. So I am not going to.
My JDK in case anyone is wondering is 1.6.
2 comments:
So, I think that you are seeing a warning, not an error. Generics are just a way of specifying that this list contains objects of type 'x', and you can operate on them directly, rather than using a casting statement first. Are you definitely getting errors? Or just warnings? The old way of loading lists is still supported.
When you do something like
List awardsList = AwardLoader.loadByUserName("troublemaker");
it returns a List of "Award" objects
so what Java is asking you (warning)to do is that you specify it
so basically if you did
List< Award > awardList .....
the warning would go away (note the spaces are so that I can publish my comment)
so basically you're type checking That way, if the function returned something other than a list of Award objects, it would throw an error.
Post a Comment