5 Replies Latest reply on Oct 13, 2008 4:33 AM by roberto

    Problem with java.sql.Date as Variable

      Hi
      I create a Process Instance and set as variable an object of type "java.sql.Date", but when I read it back it is returned as "java.sql.Timestamp".

      There is a way to avoid this automatic conversion?

      I'm using jbpm 3.2.3

      thanks

        • 1. Re: Problem with java.sql.Date as Variable

          I found the problem (I believe....) but I don't know how to fix it.
          I believe it is a problem related to hibernate.
          The JBPM_VARIABLEINSTANCE table contains a column DATEVALUE_ of type "timestamp" and the hibernate mapping use that column for every java.util.Date (or extends) classes.
          So java.sql.Date will be a java.sql.Timestamp when read it back.
          So, I believe it is necessary to change this behaviours.
          I believe there are only 2 way:
          1) add 2 new columns to JBPM_VARIABLEINSTANCE in order to add a Date and a Time column.
          add mapping for this 2 new column

          2) change the org.jbpm.context.exe.variableinstance.DateInstance (...create a new class estending from it) that analize data and return back a java.sql.Date or a java.sql.Time or a java.sql.Timestamp according column value.

          but.. I don't know hibernate .. so I believe this is not the right way and/or how to do it

          Can someone help me ?
          thanks

          • 2. Re: Problem with java.sql.Date as Variable
            kukeltje

            why don't you just use a java.util.Date?

            Much easier, future proof etc...

            • 3. Re: Problem with java.sql.Date as Variable

              it is very simple.
              My ERP application use java.sql.Date, java.sql.Timestamp and java.sql.Time field/columns.
              I need to set ERP column as variable in the process instance and read it back and obtain the same object.

              • 4. Re: Problem with java.sql.Date as Variable
                kukeltje

                the same object? or the same value? A small wrapper to convert it for you is much easier I think then making changes to the jBPM core. Or you can even try to write a converter for jBPM. (see the testcases in the source how this can be done).

                • 5. Re: Problem with java.sql.Date as Variable

                  Thanks for all kukeltje.
                  I decide to convert myself from java.sql.Timestamp returned by jBPM to my right java type.
                  it is only some additional operations (of course less code.. better performnace... :) )