You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Joacim Turesson <jo...@profuture.se> on 2004/06/09 14:10:01 UTC
Criteria with Like using Oracle
Hi!
I'm using Torque with Oracle9i and it works fine.
But now I have a problem with a select statement.
We have a node table that has a key, for instance:
* \ (for root)
* \\Folder1 <file:///\\Folder1>
* \\Folder1\Folder2 <file:///\\Folder1\Folder2>
If I use the code in the end of this mail the query works fine for a search
from the root, that is "key like '\\%'.
But when the node key value is '\\Folder1\%' the like statement is not
generated, instead it becomes key='\Folder1\'
Does anyone have a clue what's going on?
The Code:
Criteria criteria = new Criteria();
criteria.add(NodePeer.LEVEL,node.getLevel() + 1);
String nodeKey = node.getKey() + "\\" + "%";
criteria.add(NodePeer.KEY, (Object)nodeKey, Criteria.LIKE);
criteria.addAscendingOrderByColumn(NodePeer.NAME);
List list = NodePeer.doSelect(criteria,connection);
Thanks in advance!
Best Regards
Joacim Turesson
PS It works fine if I use / instead of \ DS
SV: Criteria with Like using Oracle
Posted by Joacim Turesson <jo...@profuture.se>.
Hi!
Yes, in java I use '\\'.
So for '\\%' from java using LIKE it works fine, but with '\\\\Folder1\\%'
in java Torque transform it to EQUAL to '\\Folder\\'
Could it have something to do with that we have '\\\\Folder'?
Like I said, it works with '/'.
That is, '//%' and '////Folder1//%' both using LIKE.
Best Regards
Joacim
-----Ursprungligt meddelande-----
Från: joop [mailto:joop@gmx.co.uk]
Skickat: den 9 juni 2004 20:33
Till: Apache Torque Users List
Ämne: RE: Criteria with Like using Oracle
have you tried double escaping?
ie \\Folder1\\%
-----Original Message-----
From: Joacim Turesson [mailto:joacim.turesson@profuture.se]
Sent: 09 June 2004 13:10
To: torque-user@db.apache.org
Subject: Criteria with Like using Oracle
Hi!
I'm using Torque with Oracle9i and it works fine.
But now I have a problem with a select statement.
We have a node table that has a key, for instance:
* \ (for root)
* \\Folder1 <file:///\\Folder1>
* \\Folder1\Folder2 <file:///\\Folder1\Folder2>
If I use the code in the end of this mail the query works fine for a search
from the root, that is "key like '\\%'.
But when the node key value is '\\Folder1\%' the like statement is not
generated, instead it becomes key='\Folder1\'
Does anyone have a clue what's going on?
The Code:
Criteria criteria = new Criteria();
criteria.add(NodePeer.LEVEL,node.getLevel() + 1);
String nodeKey = node.getKey() + "\\" + "%";
criteria.add(NodePeer.KEY, (Object)nodeKey, Criteria.LIKE);
criteria.addAscendingOrderByColumn(NodePeer.NAME);
List list = NodePeer.doSelect(criteria,connection);
Thanks in advance!
Best Regards
Joacim Turesson
PS It works fine if I use / instead of \ DS
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
RE: Criteria with Like using Oracle
Posted by joop <jo...@gmx.co.uk>.
have you tried double escaping?
ie \\Folder1\\%
-----Original Message-----
From: Joacim Turesson [mailto:joacim.turesson@profuture.se]
Sent: 09 June 2004 13:10
To: torque-user@db.apache.org
Subject: Criteria with Like using Oracle
Hi!
I'm using Torque with Oracle9i and it works fine.
But now I have a problem with a select statement.
We have a node table that has a key, for instance:
* \ (for root)
* \\Folder1 <file:///\\Folder1>
* \\Folder1\Folder2 <file:///\\Folder1\Folder2>
If I use the code in the end of this mail the query works fine for a search
from the root, that is "key like '\\%'.
But when the node key value is '\\Folder1\%' the like statement is not
generated, instead it becomes key='\Folder1\'
Does anyone have a clue what's going on?
The Code:
Criteria criteria = new Criteria();
criteria.add(NodePeer.LEVEL,node.getLevel() + 1);
String nodeKey = node.getKey() + "\\" + "%";
criteria.add(NodePeer.KEY, (Object)nodeKey, Criteria.LIKE);
criteria.addAscendingOrderByColumn(NodePeer.NAME);
List list = NodePeer.doSelect(criteria,connection);
Thanks in advance!
Best Regards
Joacim Turesson
PS It works fine if I use / instead of \ DS
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org