0 Replies Latest reply on Mar 1, 2004 4:14 AM by azzazzel

    Pre-check length of VARCHAR fields

    azzazzel

      Hi,
      We have application which is supposed to work with two different databases. So far we have done it using CMP and appropriate data mapping, without big problems. Unfortunately it turned out that there is big difference in how these databases handle situations where data inserted into VARCHAR field is longer then field's length. One database throws java.sql.DataTruncation, while the other one silently inserts trimmed string.

      What we need is to check the length of strings before we call ejbCreate or setXXXX(). The problem is that we don't really know what the length of given string is supposed to be. We could of course hard code it, but we just thought that since the EJB container (CMP engine) has this information (from the deployment descriptor) we could somehow make use of it.

      So, can we somehow obtain from the server what is the exact SQL type of given CMP field?

      Thanks in advance,
      Milen Dyankov

      P.S. Is it possible to force the CMP container to check for correct data (like length of string fields) on the base of what is declared in the deployment descriptor! It would be nice to have the container taking care of such issues.