On Jul 20, 2005, at 8:49 AM, Michael Watzek wrote:
Hi Andy,
I extended the test program to make objects persistent using JPOX in addition to the JDBC test I described below:
There is a persistence capable class having a field of type "char".
There is a table having a single column of type "CHAR(1)". The orm metadata for this class specifies a field mapping from the "char" field to the "CHAR(1)" column. The orm column attribute "jdbc-type" is omitted. Thus, the JPOX default is used.
When an object is made persistent using that mapping, then Derby throws error 22001 (see below).
But if the mapping contains the orm column attribute "jdbc-type" setting it to "CHAR" explicitly, then Derby does not throw that error. Instead, pm.makePersistent succeeds.
It seems, that JPOX does not default orm column attribute "jdbc-type" to "CHAR" if the field is of type "char" or "java.lang.Character". Instead, JPOX defaults to a numerical type, e.g. "INTEGER". Can you verify that?
Craig,
the spec specifies in chapter 18.5:
"The jdbc-type attribute declares the type of the column in the database. This type is defaulted based on the type of the field being mapped."
Does this mean, that an implementation may choose for an default?
That was not the intent. The intent was that the JDBC type would be obvious. ;-) And the "obvious" jdbc-type for char and Character is CHAR. I'll raise this issue with the JDO experts to be sure.
Another question: The TCK orm metadata does not specify column attribute "jdbc-type". Thus, implementations use their default when the TCK runs. Does it make sense, to add the jdbc type to all column attributes ensuring that the mapping fits to the database schema?
I don't want to add the jdbc-type because it's not supposed to be needed for the simple TCK tests. I had thought that we should add jdbc-type for completeness, just to make sure the JDO implementation can handle it, but not in the general case.