db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandeep S. Chhikara" <schhik...@hotmail.com>
Subject java escape character save retrieve problem
Date Wed, 23 Jun 2004 16:59:51 GMT
Hi F. FrayYes you understanding is correct. And code sample is exactly same as you have sent.
WOrking on your example, after save() method call the database will have valueC:\dev\test\myfile.doc
 for column FILEPATH.However, in load() method this call List hits = FileObjectPeer.doSelect(criteria);
will always return emply list since torque criteria object will generate sql where clause
as select ......from ... where FILEPATH ='C:\\dev\\test\\myfile.doc'and since database contains
this value as 'C:\dev\test\myfile.doc' nothing will be ever returned.Now if you guys are starting
up on this project, i would suggest use"/" as path separator and everything will be ok, since
this will not need java escapecharacter.Please do reply, for suggestion to fix the strange
behaviour of torque criteria objects.thanksSandeep Chhikara
From: florianfray@compuserve.de <florianfray@compuserve.de>
Date: Wed, 23 Jun 2004 08:22:16 +0200
Subject: java escape character save retrieve problem
Content-Type: multipart/mixed; boundary="--d6f740d669e2f95"

Good Morning Sandeep!

Don't know if I did understand you right. You say:
Saving a String with slashes works correct, but retrieving such rows
doesn't work?
Please send a code snippet! Would interest me since we have to do this,
Is it something like: 

void save() {
  FileObject f = new FileObject();
  try {
  } catch (Exception e) {

FileObject load() {
  Criteria criteria = new Criteria();
  criteria.add(FileObjectPeer.PATH, "C:\\dev\\test\\myfile.doc");
  try {
    FileObject f;
    List hits = FileObjectPeer.doSelect(criteria);
    if (hits.size() == 0) {
      f = null;
    } else {
      f = (FileObject) hits.get(0);
    return f;
  } catch (Exception e) {
    return null;


??? Please send your code!

F. Fray

----- Originalnachricht -----
Von: "Sandeep S. Chhikara" <schhikara@inventes.com>
Datum: Dienstag, 22. Juni 2004 10:53 pm
Betreff: java escape character save retrieve problem

> Good Afternoon Everyone, 
> I am using torque 3.1 and experiencing a strange problem with 
> escape character in dir path.
> Environment:
> jdk1.4
> torque 3.1
> MSSQlServer 2000
> OS: windows 2000 server
> In database table, i have a column to store filePath.
> I read a file path from file which is "SINGLE \" 
> C:\dev\test\myfile.docand since java adds a escape"\" character so 
> in debugging i see this path as " DOUBLE \\" 
> but while saving in DB torque saves this correctly,as expected 
> "SINGLE \" C:\\dev\\test\\myfile.doc.
> When i try to retrieve this data using torque criteria the 
> filePath set as  "SINGLE \" C:\dev\test\myfile.doc
> and as discussed earlier java adds escape character torque 
> criteria has filePath value " DOUBLE \\" C:\\dev\\test\\myfile.doc.
> Now i never get the saved row back, since db value  "SINGLE \" 
> C:\dev\test\myfile.doc will never match with 
>  DOUBLE \\" C:\\dev\\test\\myfile.doc and hence no row is 
> returned back.
> The above mentioned example works fine with path as 
> C:/dev/test/myfile.doc ie saving and retrieval works.
> Please suggest how can i fix this problem, and make torque save 
> and retrieve same value.
> thanks
> Sandeep Chhikara

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message