Re: How to strip off selected columns from a criteria object

2010-05-21 Thread wzhao6...@gmail.com
Hi Thomas,

Thanks a lot, just tried this, worked like a charm.
BTW, Criteria object returned by criteria.clone() gets affected if the
original criteria object is modified. Is this a bug?
For examples, if I have an existing criteria, then I do:
Criteria criteriaClone = criteria.clone();
criteria.getSelectColumns().clean();

both criteria and criteriaClone have empty selectcolumn list.
Thanks,



David

On Mon, May 10, 2010 at 1:02 PM, Thomas Vandahl t...@apache.org wrote:

 Hi Dave,

 wzhao6...@gmail.com schrieb:

  Thanks for your reply. But what I need to deal with is that:
 I have a criteria object, with joins, and where clauses and a list of
 columns to select, and I need to remove all the selected columns in the
 criteria, both selected column, and as columns, so I can use OMPeer class
 to
 select a list of OM objects;


 What happens if you do criteria.getSelectColumns().clear() or
 criteria.getAsColumns().clear(), respectively? Would that help?
 (This is what is basically done in criteria.clear(), among other things)


 Bye, Thomas.

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




Re: How to strip off selected columns from a criteria object

2010-05-10 Thread wzhao6...@gmail.com
Hi Thomas,

Thanks for your reply. But what I need to deal with is that:
I have a criteria object, with joins, and where clauses and a list of
columns to select, and I need to remove all the selected columns in the
criteria, both selected column, and as columns, so I can use OMPeer class to
select a list of OM objects;
Thanks again!

David


On Thu, May 6, 2010 at 8:39 AM, Thomas Vandahl t...@apache.org wrote:

 On 05.05.10 23:28, wzhao6...@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-unsubscr...@db.apache.org
 For additional commands, e-mail: torque-user-h...@db.apache.org




Re: How to strip off selected columns from a criteria object

2010-05-10 Thread Thomas Vandahl

Hi Dave,

wzhao6...@gmail.com schrieb:

Thanks for your reply. But what I need to deal with is that:
I have a criteria object, with joins, and where clauses and a list of
columns to select, and I need to remove all the selected columns in the
criteria, both selected column, and as columns, so I can use OMPeer class to
select a list of OM objects;


What happens if you do criteria.getSelectColumns().clear() or 
criteria.getAsColumns().clear(), respectively? Would that help?

(This is what is basically done in criteria.clear(), among other things)

Bye, Thomas.

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



Re: How to strip off selected columns from a criteria object

2010-05-06 Thread Shaista Shekh
U can use following command..
Whatever column's value  u want to get u have to mention that's column name
.

crit.addGroupByColumn(TurbineUserPeer.USER_LANG);

2010/5/6 wzhao6...@gmail.com wzhao6...@gmail.com

 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.

 I understand that criteria is essentially a HashTable, but only WHERE
 clause
 (through criteria.add(...) ) has a key in criteria, I can't find join and
 column
 key information from the criteria.keySet()?

 BTW, how do I re-construct a criteria by putting all the pieces in criteria
 together? I don't want to use criteria.clone() in this case.
 Thanks in advance!

 David



Re: How to strip off selected columns from a criteria object

2010-05-06 Thread Thomas Vandahl
On 05.05.10 23:28, wzhao6...@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-unsubscr...@db.apache.org
For additional commands, e-mail: torque-user-h...@db.apache.org