0 Replies Latest reply on May 22, 2002 9:01 AM by gemerick

    SQL 2000 uniqueidentifier and custom type mapping

    gemerick

      I'm using SQL 2000 uniqueidentifer data type in my tables. I have been able to deploy and run EJB's based on these tables in jboss 3.0rc1. The uniqueidentifier columns are represented as byte arrays in the EJBs. My current type mapping uses java.lang.Object for the java-type. The main problem is that byte[] is tough to deal with in the accessing jsp pages. That is, to be used in forms and urls they have to be converted to strings and then back to byte[] again.

      I would like to be able to map these columns into a custom object via the type mapping in standardjbosscmp-jdbc.xml. For example:

      <type-mapping>
      MS SQLSERVER2000
      ...

      <java-type>mycustom.guidObject</java-type>
      <jdbc-type>BINARY</jdbc-type>
      <sql-type>UNIQUEIDENTIFIER</sql-type>

      ...

      The object could then deal with the conversions from byte[] to string and reverse, internally.

      Has anyone else out there used the uniqueidentifier data type in ms sql? If so, any suggestions on simplifying usage?

      Can anyone help me with the syntax for the mycustom.guidObject, mentioned above? I took a shot at it with a class that implements Serializable and has a constructor that takes a byte[]. I got the following error:

      2002-05-21 14:39:23,285 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.Asset.findAll] Find failed
      javax.ejb.EJBException: Internal error getting results for field member guid
      Embedded Exception
      Unable to load to deserialize result: java.io.StreamCorruptedException: invalid stream header
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadArgumentResults(JDBCAbstractCMPFieldBridge.java:360)