Max,

Thanks for your recommendation.
Sometimes, database design is a fixed variable, therefore you cannot alter
database design  (this database  is actually in use from some other apps).
It seems that Jakob´s tips is the right path (hope it works even when
changing back-end RDBMS ).

Again, thank you very much.
Gustavo.



                                                                                       
                              
                    "Geigl                                                             
                              
                    Maximilian,            To:     "OJB Users List" <[EMAIL 
PROTECTED]>                         
                    R235"                  cc:                                         
                              
                    <Geigl.Maximilia       Subject:     AW: OJB criteria fails with 
Oracle char field right filled   
                    [EMAIL PROTECTED]>              with spaces                        
                                      
                                                                                       
                              
                    19/03/2003 14:20                                                   
                              
                    Please respond                                                     
                              
                    to "OJB Users                                                      
                              
                    List"                                                              
                              
                                                                                       
                              
                                                                                       
                              




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]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to