You can't cast a List to a Set but you can create a Set from a List. List myList = manager.getAll(); Set uniqueList = new HashSet(myList);
No iteration or casting needed! ;-) George.Francis wrote: > > Doing this cast causes the following exception to be thrown from Manage > Users: > > org.springframework.web.util.NestedServletException: Request processing > failed; nested exception is java.lang.ClassCastException: > java.util.ArrayList cannot be cast to java.util.LinkedHashSet > Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be > cast to java.util.LinkedHashSet > at > com.ism.ismid.webapp.controller.UserController.handleRequest(UserController.java:44) > at > org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) > > > > syg6 wrote: >> >> Yep. You're using Hibernate right? Just cast the List of Users to a >> LinkedHashSet in your UserController. List allows duplicates, Sets do >> not. >> >> Cheers, >> Bob >> >> >> George.Francis wrote: >>> >>> I'm getting some strange behaviour. I find that if I assign two Roles >>> to User 'admin' then when I call >>> userManager.getAll() I get two instances of the admin user in the List. >>> Has anyone else seen this kind of behaviour? What causes it? >>> >> >> > > -- View this message in context: http://www.nabble.com/Duplicate-Users-in-List-tf4699959s2369.html#a13739481 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
