Hi,

we switched to VARCHAR2 (instead of CHAR) for the same reason; maybe more convenient 
than using  trim() all the time.

Regards
Max

> -----Urspr�ngliche Nachricht-----
> Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 19. M�rz 2003 16:56
> An: 'OJB Users List'
> Betreff: OJB criteria fails with Oracle char field right filled with
> spaces
> 
> 
> 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]

Reply via email to