From: Alistair Y. <ali...@sm...> - 2006-05-23 11:52:43
|
That's really weird. So the only way you can get a UserDetail from a PrimaryKey is if you have the PrimaryKey of the UserDetail which you got from the UserDetail? and PrimaryKey can mean anything! It's a VARIANT in COM speak. Roll on Tetra! Alistair On 22 May 2006, at 21:22, Matthew Buckett wrote: > Alistair Young wrote: >> Before I dive off into bodguts, has anyone seen this before, or >> any suggestions as to why it happens? >> UserDetail bodUserDetail = UserDetail.findUserDetail >> (user.getPrimaryKey()) >> where user = org.bodington.server.realm.User > > Yep this is because UserDetail has it's own primary key and the > primary key of the refering User. Your asking for the UserDetail > object with the primary key of the User which doesn't exist. > >> always gives a ClassCastException. Is a User.PrimaryKey different >> from a UserDetail.PrimaryKey? > > You get this because the database layer is trying to case a User > object found by its primary key into a UserDetail object. > >> Always have to use sql to get UserDetail from a User. > > Yep. UserDetail.findUserDetail("user_id = ?"); Or make a > findUserDetailByUser which does the SQL behind the scenes. You may > also want to make user_id an indexkey if performance becomes a > problem. > > -- > -- Matthew Buckett, VLE Developer > -- Learning Technologies Group, Oxford University Computing Services > -- Tel: +44 (0)1865 283660 http://www.oucs.ox.ac.uk/ltg/ > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, > security? > Get stuff done quickly with pre-integrated technology to make your > job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > http://sel.as-us.falkag.net/sel? > cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Bodington-developers mailing list > Bod...@li... > https://lists.sourceforge.net/lists/listinfo/bodington-developers |