Hi Jakob, Thank you very much for your help. It worked. I did not know I could use trim right there. Any pointer to the OBJ documentation where I can read more about this?
Best Regards, Gustavo. Jakob Braeuchi <[EMAIL PROTECTED] To: OJB Users List <[EMAIL PROTECTED]> .ch> cc: Subject: Re: OJB criteria fails with Oracle char field right filled 19/03/2003 with spaces 13:30 Please respond to "OJB Users List" hi gustavo, why can't you use trim or an equivalent oracle-function to get rid of the spaces ? mycrit.addEqualTo("trim(firstName)", "Gustavo"); hth jakob [EMAIL PROTECTED] wrote: >Hi all, > >We are using OJB, Oracle 9i. When trying to retrieve an object by criteria, >OJB is not finding the requested object since the CHAR fields are right >filled with spaces. > >Just an example: > >oracle table emp >field name: FIRST_NAME(CHAR10) > >object Emp, attribute firstName > >Object/Record to to retrieve should have firstName = Gustavo (this was >stored using OJB; Oracle fills with spaces to the right of the user >inserted string in a CHAR field) > >This will work: OJB will return the object if criteria sets emp.firstName >to "Gustavo " (note the 3 spaces at the right): >Criteria mycrit = new Criteria(); >mycrit.addEqualTo("firstName", "Gustavo "); >Query myquery = new QueryByCriteria(emp.class, mycrit); >myemp= (Emp)broker.getObjectByQuery(myquery); > >This will not work: OJB will fail to return the object if criteria is set >to emp.firstName = "Gustavo" (no spaces). >Criteria mycrit = new Criteria(); >mycrit.addEqualTo("firstName", "Gustavo"); >Query myquery = new QueryByCriteria(emp.class, mycrit); >myemp= (Emp)broker.getObjectByQuery(myquery); > >Problem here is that the java coder has to know the database field lenght >in order to fill the string with the right number of spaces. It´s our >understanding that OJB should take care of the the object.attribute ==> >RDBMS mapping without requiring the programmer to take care of things like >this. > >We´ve tested setting criteria to SQL string and it works, but again, this >approach requires us to "wire" some database specific things like field >names to our java code. > >Criteria mycrit = new Criteria(); >crit.addSql("FIRST_NAME = 'Gustavo'"); >Query query = new QueryByCriteria(Usuario.class, crit); >myemp = (Emp) broker.getObjectByQuery(query); > >Are we missing something here? Any ideas? > >Thanks in advance > >Gustavo Faerman >Buenos Aires, >Argentina. > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]