[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6802) NullPointerException in addValueToMiddleTable with @MapKeyJoinColumn

Marcin Kobylarz (JIRA) noreply at atlassian.com
Fri Nov 4 05:17:22 EDT 2011


NullPointerException in addValueToMiddleTable with @MapKeyJoinColumn
--------------------------------------------------------------------

                 Key: HHH-6802
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6802
             Project: Hibernate Core
          Issue Type: Bug
          Components: envers
    Affects Versions: 3.6.8
         Environment: Hibernate + Envers 3.6.8
            Reporter: Marcin Kobylarz


The following mapping:

@Audited
@OneToMany(mappedBy = "formData", cascade = CascadeType.ALL, orphanRemoval = true)
@MapKeyJoinColumn(name = "SPR_FORMULARZ_MODEL_POLE_ID", nullable = false)
private Map<FieldModel, FormFieldValue> values = new HashMap<FieldModel, FormFieldValue();

causes the exception while bringing hibernate up:
Caused by: java.lang.NullPointerException
    at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addValueToMiddleTable(CollectionMetadataGenerator.java:458)
    at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addIndex(CollectionMetadataGenerator.java:398)
    at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addOneToManyAttached(CollectionMetadataGenerator.java:196)
    at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:157)
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator.java:204)
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties(AuditMetadataGenerator.java:223)
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateSecondPass(AuditMetadataGenerator.java:484)
    at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:115)
    at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:97)
    at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:129)
    at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:337)
    at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
    at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
    at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)

This is caused because queryGeneratorBuilder is null in the addValueToMiddleTable:458 method.

We suppose that method AuditedPropertiesReader:289:

private void addPropertyMapKey(XProperty property, PropertyAuditingData propertyData) {        
   MapKey mapKey = property.getAnnotation(MapKey.class);        
   if (mapKey != null) {
      propertyData.setMapKey(mapKey.name());        
   }    
}

needs improvement to accept also @MapKeyJoinColumn annotation not only @MapKey.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list