3 Replies Latest reply on Oct 16, 2001 4:30 PM by Adam Young

    boolean CMP fields not sticking...

    Neal Sanche Newbie

      Hey All,

      I've been noticing intermittent problems with 'boolean' fields of CMP beans not remembering their state. I'm using the InstantDB, and the java native 'boolean' type for the getters and setters. I'm using 2.4.1 JBoss.

      What I do is set the values of the booleans, in this case a field named 'enabled' from my client (I'm accessing the CMP bean directly instead of through a session facade). As long as the server is running, it seems to take effect.

      If I shut down JBoss (Ctrl-C) and start it back up again, my boolean field 'enabled' is always false.

      Should I be using java.lang.Boolean for boolean fields? All of my 'int' fields seem to stick. I don't see any transaction rollbacks, and the SQL that rolls by looks okayish:

      UPDATE Modem SET state = 0 , handshake = 1 , parity = 3 , portName = /dev/ttyS1 , busy = false , initString = AT&F1 , enabled = true , stopBits = 1 , direction = 1 , portSpeed = 57600 , dataBits = 8 WHERE portName = /dev/ttyS1

      I'm not so sure about the enabled = true thing there. Does InstantDB handle that kind of Syntax? Maybe that's the problem?


        • 1. Re: boolean CMP fields not sticking...
          Jeremy Clemenson Newbie

          Hey All,

          We are seeing the same problem with boolean cmp fields not sticking after jboss bounces. This is for postgres with JBoss 2.4.1A. Would using the Boolean wrapper class work better?

          Thanks in advance for any help,

          • 2. Re: boolean CMP fields not sticking...
            Neal Sanche Newbie

            Well, I figured out that booleans stick just fine with the Hypersonic database, so I've switched over to using that since my data requirements are quite lean. Hypersonic seems to be much faster for what I need, as well.


            • 3. Re: boolean CMP fields not sticking...
              Adam Young Newbie

              I've noticed this as welll (and looking for a solution to this problem brought me to this forum). I think the problem might stem from the fact that JDBC does not define a Boolean type. If you look in the Postgres Section of the standardjaws.xml, you will notice that they mapped boolean to the int2 SQL type and the SMALLINT JDBC type. THE JDBC types are defined in the Class Types (a pseudo enumeration) defined in the java.sql package.

              However, I notice that they seem to update the DB correctly while running (assuming 1 is true and 0 is false). It just seems to get wiped out when it redeploys. I wonder if the Cache in the EJB which get's flushed when it is redeployed is incorrectly overwriting the value.

              In some code we've implemented in the Struts layer, we do a direct JDBC call that reads the values out of the DB. This is reading both 0 and 1 as false. Could this be a problem in the PostgreSQL jdbc driver? Or is this mapping not supported somehow?