You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by giovanni <gi...@sesaspa.it> on 2003/04/15 16:22:32 UTC

Possible bug in rc2 (field is not validated as in db) ?

Hello All,

I am using OJB (ver 1.0rc2) inside a servlet and I use the persistence
broker api to persist my objs.
The other 'items' I have are:
   Mysql 4.0.12
   Tomcat 4.1.24

What happens is that when I retrieve a persistent class, an attribute is not
validated with the same value as the one
that I have in the DB.

The table that I have is created with :
CREATE TABLE PROJECT(CONTEXT_ID INTEGER NOT NULL,PROJECT_ID INTEGER NOT
NULL,
PARENT_ID INTEGER NOT NULL, EXPANDED INTEGER NOT NULL, TYPE VARCHAR(255) NOT
NULL,
NAME VARCHAR(255) NOT NULL,CODE VARCHAR(255),DESCRIPTION VARCHAR(255),
PRIMARY KEY(PROJECT_ID));


The mapping that I have is:

<class-descriptor
    class="xxx.Project"
    table="PROJECT"
>
<field-descriptor
id="1"
name="contextId"
column="CONTEXT_ID"
jdbc-type="INTEGER"
nullable="false"
/>
<field-descriptor
id="2"
name="projectId"
column="PROJECT_ID"
jdbc-type="INTEGER"
primarykey="true"
/>
<field-descriptor
id="3"
name="parentId"
column="PARENT_ID"
jdbc-type="INTEGER"
nullable="false"
/>

<field-descriptor
id="4"
name="expanded"
column="EXPANDED"
jdbc-type="INTEGER"
nullable="false"
/>

<field-descriptor
id="5"
name="type"
column="TYPE"
jdbc-type="VARCHAR"
nullable="false"
/>

<field-descriptor
id="6"
name="projectName"
column="NAME"
jdbc-type="VARCHAR"
nullable="false"
/>

<field-descriptor
id="7"
name="code"
column="CODE"
jdbc-type="VARCHAR"
nullable="true"
/>

<field-descriptor
id="8"
name="description"
column="DESCRIPTION"
jdbc-type="VARCHAR"
nullable="true"
/>

</class-descriptor>

 A project may have different child projects. In that case the expanded
field is set to 1, otherwise it is set to 0.

What happens is that when I start the servlet and insert some children prjs
to the main one everything is fine,
the main prj get expanded=1 and I can see in a form the children.
Now if I quit the web-application and login again, I can only see still the
main (root) project.
What I can see is that even if in the db table the value is set to one, the
expanded field in the class
keeps the value of 0. All the other attributes are set correctly. Also I can
see that
- the query in the log file is the correct one
- If a provide a field conversion function, the Integer value that is read
from the DB is correct (1), but
  the expanded class field still keeps it's value to 0.

Note also that originally the EXPANDED field was a BIT, but I've changed
that in order to be sure nothing
strange might happen. (This is my first exposure to OJB but anyway I had
also the problem with the BIT/boolean types).

At last, if I have the wrong behaviour but then enter some values in another
DB table using anothe form, then -as by magic-
when I go back to the buggy form, everything is ok ! (It seems I get the
correct value back again until the next login)

Any help would be most appreciated.

Thanks in advance,
Giovanni


Note: I've sent that message also to ojb-user-help but I guess that was a
mistake :)