Actually, it appears that there is a better way to solve this issue. The TurbineSecurity service calls the underlying DBUserManager class to do the query. DBUserManager walks through the Criteria object and automatically adds the table name to the columns that don't already have a table name, which is why using User.XXXX works for the WHERE clause stuff. It just doesn't do this for any sorting specifications.
We (probably Eric Dobbs) will submit a patch if we can get this to work. Then you could use the User.XXXX column names for sorting, too. Kevin > -----Original Message----- > From: Will Glass-Husain [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, February 19, 2002 11:50 AM > To: Turbine Users List > Subject: RE: Sorting a list of users -- exception > > > Thanks Kevin! > > Just to close out the thread, the following worked fine. > > Criteria crit2 = new Criteria(); > UserPeer up = > ((DBSecurityService)TurbineSecurity.getService()).getUserPeerI > nstance(); > > crit2.addAscendingOrderByColumn(up.getFullColumnName(UserPeer. > USERNAME)); > User[] UserList = TurbineSecurity.getUsers(crit2); > > context.put("UserList",UserList); > > Bug report-- > > Without using the full column name (as above), I was getting > an exception on > line 1030 of BasePeer: > > java.lang.StringIndexOutOfBoundsException: String index > out of range: -1 > > Looking at the code, BasePeer does > orderByColumn.indexOf('.') > > in a number of places without checking to see if the period > actually exists. > Hence this problem. This also occurs if you try to do other > operations > (e.g. a join) on the username. > > WILL > > -----Original Message----- > From: Kevin Rutherford [mailto:[EMAIL PROTECTED]] > Sent: Monday, February 18, 2002 12:47 PM > To: 'Turbine Users List' > Subject: RE: Sorting a list of users -- exception > > > Good point! As I mentioned, I haven't tried this out yet, > myself. However, I > found the following snippet of code in RolePeer.java that seems to > demonstrate a way of doing this: > > UserPeer up = > ((DBSecurityService)TurbineSecurity.getService()).getUserPeerI > nstance(); > criteria.add(up.getFullColumnName(UserPeer.USERNAME), > user.getUserName()); > ... > > I don't know if I am steering you down the wrong path or not. > I am guessing > that the get UserPeerInstance() method is not available in the > TurbineSecurity facade class because it is specific to the database > implementation (DBSecurityService.java)??? Perhaps someone > else who has > already solved this problem can respond if this is not the > correct way of > doing this... > > Kevin > > > > -----Original Message----- > > From: Will Glass-Husain [mailto:[EMAIL PROTECTED]] > > Sent: Monday, February 18, 2002 1:33 PM > > To: Turbine Users List > > Subject: RE: Sorting a list of users -- exception > > > > > > Good idea, but how do I get the instance of UserPeer? > > (getFullColumnName > > isn't a static method). > > > > Sorry if this is a basic question... just figuring some of this out. > > > > Thanks, WILL > > > > -----Original Message----- > > From: Kevin Rutherford [mailto:[EMAIL PROTECTED]] > > Sent: Monday, February 18, 2002 11:19 AM > > To: 'Turbine Users List' > > Subject: RE: Sorting a list of users -- exception > > > > > > I believe the problem is that addAscendingOrderByColumn() is > > expecting a > > full table/column name, but the User and UserPeer abstraction > > classes do not > > include the table name (intentionally, I think). > > > > Try > > addAscendingOrderByColumn(UserPeer.getFullColumnName(UserPeer. > > USERNAME)). I > > haven't tried this myself (we use TurbineUserPeer.USERNAME, > > which works but > > is not the right way to do it), but it looks like the > > getFullColumnName() > > method was created to solve this issue. > > > > Kevin > > > > > -----Original Message----- > > > From: Will Glass-Husain [mailto:[EMAIL PROTECTED]] > > > Sent: Monday, February 18, 2002 11:52 AM > > > To: Turbine Users List; [EMAIL PROTECTED] > > > Subject: RE: Sorting a list of users -- exception > > > > > > > > > Hi, > > > > > > Thanks for the note. You're right, should have tried > > > UserPeer.USERNAME. > > > Tried again, still gave the same error. Possible bug? > > > > > > Criteria crit2 = new Criteria(); > > > crit2.addAscendingOrderByColumn(UserPeer.USERNAME); > > > User[] UserList = TurbineSecurity.getUsers(crit2); > > > context.put("UserList",UserList); > > > Thanks. > > > > > > WILL > > > > > > -----Original Message----- > > > From: Colm McCartan [mailto:[EMAIL PROTECTED]] > > > Sent: Monday, February 18, 2002 10:22 AM > > > To: Turbine Users List > > > Subject: Re: Sorting a list of users -- exception > > > > > > > > > > > > > > > Will Glass-Husain wrote: > > > > > > > Hi, > > > > > > > > I tried to put a sorted list of users in my Velocity > > > context, and got an > > > > exception > > > > > > > > Criteria crit2 = new Criteria(); > > > > crit2.addAscendingOrderByColumn(User.USERNAME); > > > > > > > > > Are you sure you meant this and not UserPeer.USERNAME? > > > > > > > > > > > > colm > > > > > > > > > > > > -- > > > To unsubscribe, e-mail: > > > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > > > <mailto:[EMAIL PROTECTED]> > > > > > > > > > -- > > > To unsubscribe, e-mail: > > > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > > > <mailto:[EMAIL PROTECTED]> > > > > > > > > > -- > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
