db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Vandahl ...@apache.org>
Subject Re: How to strip off selected columns from a criteria object
Date Thu, 06 May 2010 15:39:23 GMT
On 05.05.10 23:28, wzhao6898@gmail.com wrote:
> Hi there,
> I need to strip off all the selected columns (getSelectedColumns(), and
> getAsColumns()) from a criteria object, is there a way for me to do that?
> For examples:
> Criteria criteria = new Criteria();
> criteria.addJoin(PermissionPeer.PERMISSION_ID,RolePermissionPeer.PERMISSION_ID);
> criteria.addJoin(RolePermissionPeer.ROLE_ID, RolePeer.ROLE_ID);
> criteria.add(PermissionPeer.PERMISSION_ID, 1, Criteria.EQUAL)
> criteria.addSelectColumn(PermissionPeer.PERMISSION_ID);
> criteria.addAsColumn("permission", PermissionPeer.PERMISSION_ID);
> criteria.setDistinct();
> where, I'd like to remove the selected columns:
> PermissionPeer.PERMISSION_ID,, but
> criteria.remove(PermissionPeer.PERMISSION_ID);
> doesn't do it for me.

Several databases require all columns used in the where-clause to be in
the list of selected columns, too. Furthermore, the Peer classes expect
all columns needed for the construction of the OM object to be present
in the result set. If you use BasePeer.doSelect, however, you can build
any criteria you want. You will get back Village records, though.

Bye, Thomas.

To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message