Kuali Rice Development
  1. Kuali Rice Development
  2. KULRICE-3926

Override SequenceStyleGenerator to handle Strings

    Details

    • Type: Bug Fix Bug Fix
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1-JPA
    • Component/s: Development, JPA
    • Labels:
      None
    • Similar issues:
      KULRICE-6845Problems with UifBeanFactoryPostProcessor expression handling that is causing bean property overrides (such as fieldInquiry.render) to not work
      KULRICE-8425Problems with UifBeanFactoryPostProcessor expression handling for nested properties and lists prevent bean property overrides (such as fieldInquiry.render) from working
      KULRICE-551XFire can't handle empty strings
      KULRICE-6939SimplePropositionTypeService does not handle non-string constants appropriately
      KULRICE-1194Handle the conversion of a Collection into a String in AbstractLookupableHelperServiceImpl rather than depending on Collection.toString
      KULRICE-4289improve error handling in KualiAction.performLookup(..)
      KULRICE-5344remove Attributes & AttributeSet class replace with Map<String, String>
      KULRICE-4442Person service does not handle extension objects properly
      KULRICE-5376Uif Framework - Refactor conditional expressions for non String fields
      KULRICE-8683IdentityCurrentAndArchivedServiceImpl.getDefaultNamesForPrincipalId() does not handle missing principals
    • Rice Module:
      KNS

      Description

      The KNS class MaintenanceLock puts a sequence-generated ID into a String. Hibernate doesn't like putting sequence-generated IDs into Strings. Chad described a solution:

      >>>>>
      If Hibernate cannot convert between those numbers and strings implicitly, you may need to create your own subclass of Hibernate's SequenceStyleGenerator in order to perform the number-string conversion at the appropriate times; then, on any entities with keys generated as numbers but stored as strings, set the "strategy" property on their GenericGenerator annotations to point to your new generator.
      >>>>>

      If only it was so easy. Actually several things will need to be overridden here - not only will SequenceStyleGenerator be extended, but OptimizerFactory basically needs to be copied and the logic in OptimizerSupport#make needs to be written to support Strings. Because OptimizierFactory is a non-injected class with a ton of statics, it's all kind of a mess, but that's what we'd need to do to override.

        Issue Links

          Activity

          Hide
          James Smith added a comment -

          Assigning this to me, so I can get maint docs working in the sample app.

          Show
          James Smith added a comment - Assigning this to me, so I can get maint docs working in the sample app.
          Hide
          James Smith added a comment -

          Actually, I may be able to just override the optimizer for SequenceStyleGenerator; I'll try that

          Show
          James Smith added a comment - Actually, I may be able to just override the optimizer for SequenceStyleGenerator; I'll try that
          Hide
          James Smith added a comment -

          Looks like my fix worked (hooray, it wasn't that hard) - but now I'm running into an issue of save order (ie, it tried to save krns_maint_doc_t before krns_doc_hdr_t) that I want to get ironed out before committing this.

          Show
          James Smith added a comment - Looks like my fix worked (hooray, it wasn't that hard) - but now I'm running into an issue of save order (ie, it tried to save krns_maint_doc_t before krns_doc_hdr_t) that I want to get ironed out before committing this.
          Hide
          James Smith added a comment -

          So all I needed to do was to update the optimizer. That can be fixed as so:

          @Id
          @GeneratedValue(generator="KRNS_MAINT_LOCK_S")
          @GenericGenerator(name="KRNS_MAINT_LOCK_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters=

          { @Parameter(name="sequence_name",value="KRNS_MAINT_LOCK_S"), @Parameter(name="value_column",value="id"), @Parameter(name="optimizer",value="org.kuali.rice.core.jpa.spring.StringHandlingNoOpSequenceOptimizer") }

          )
          @Column(name="MAINT_LOCK_ID")
          private String lockId;

          (note the optimizer parameter sent in to the sequence).

          I have confirmed this works - yay.

          Show
          James Smith added a comment - So all I needed to do was to update the optimizer. That can be fixed as so: @Id @GeneratedValue(generator="KRNS_MAINT_LOCK_S") @GenericGenerator(name="KRNS_MAINT_LOCK_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters= { @Parameter(name="sequence_name",value="KRNS_MAINT_LOCK_S"), @Parameter(name="value_column",value="id"), @Parameter(name="optimizer",value="org.kuali.rice.core.jpa.spring.StringHandlingNoOpSequenceOptimizer") } ) @Column(name="MAINT_LOCK_ID") private String lockId; (note the optimizer parameter sent in to the sequence). I have confirmed this works - yay.

            People

            • Assignee:
              James Smith
              Reporter:
              James Smith
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Structure Helper Panel