4 Replies Latest reply on Sep 27, 2008 4:01 AM by adamw

    Handling of custom UserTypes

    klercker

      Hi,

      We are currently evaluating using Envers in our app, and it's looking pretty good so far. One problem is that we use a custom UserType. It's pretty simple (it maps the type to a string and stores state as XML), so it should *really* be no problem to version a property of this type. There are of course also alternative ways to implement the mapping, so everything is not lost anyway.

      What are the issues with supporting custom UserTypes, and could there be ways of going around the current limitation at least for simpler implementations of UserType? We've noticed that Envers already supports two custom types, so there are obviously gray areas where perhaps we could contribute?

      cheers,
      /Mans

        • 1. Re: Handling of custom UserTypes
          plaky

          Hello,

          you can find the typemapping in org.jboss.envers.metadata.VersionsMetadataGenerator.
          I'm not really familiar with the property and type-mapping, but I think you need to:

          1.) Extends the method addProperties(..) to handle a UserType
          2.) Build corresponding mappings for the user-type
          3.) Build a mapper for this (every) user-type to track changes on this object

          Maybe more changes are needed, this is only what I found during work on extending envers.

          Kind regards,

          Sebastian

          • 2. Re: Handling of custom UserTypes
            adamw

            Hello,

            I think for most user types it would be sufficient to generate a mapping exactly as in VersionsMetadataGenerator.addSimpleProperty, but additionally copying the user-type attribute. Please create a JIRA issue, and if you have some simple user type to test with please attach it as well, it surely will be helpful.

            --
            Adam

            • 3. Re: Handling of custom UserTypes
              adepue

              Just in case you miss it from the issue itself, I've run into a problem during testing of the new feature: my custom type is being written to the DB OK, but it is not being read from the DB (or not being set on the entity). I'm still digging into it...

              • 4. Re: Handling of custom UserTypes
                adamw

                Ok, when you'll have some results, please let me know :).

                The class org.jboss.envers.test.entities.customtype.CompositeTestUserType is based on your Money custom type, and in tests it works :) Maybe you can look there for differences.

                --
                Adam