The specified workaround for error HHH-9114 from Michael works , for example. in my case, adding to TwitterListedCount : (note that in order for user types to still work, both @Id and @Type must be added)
// TODO: https://hibernate.atlassian.net/browse/HHH-9114 @Override @Id public long getTwitterUserId() { return super.getTwitterUserId(); } @Override @Id public DateTime getFetchTime() { return super.getFetchTime(); }
By the way, the workaround has the unpleasant side effect of HHH-9350 when used with circuit generation , it generates repeating composite columns:
CREATE TABLE buzz.twitterlistedcount ( id_fetchtime timestamp without time zone NOT NULL, id_twitteruserid bigint NOT NULL, _identifiermapper_fetchtime timestamp without time zone NOT NULL, _identifiermapper_twitteruserid bigint NOT NULL, listedcount integer NOT NULL, CONSTRAINT twitterlistedcount_pkey PRIMARY KEY (id_fetchtime, id_twitteruserid) ) WITH ( OIDS=FALSE );
I tried not to use @MappedSuperclass at all, but the wrong schema creation is still happening. BTW I am using DefaultComponentSafeNamingStrategy where there may be an error. This is probably another error set in Hibernate find with a composite key. Invalid column name exception
The correct workaround involves adding @Column(name=) manually, which works well with generating the schema:
@Id @Basic() @Column(name="twitteruserid") private long twitterUserId = 0; @Id @Basic() @Column(name="fetchtime") @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime") private DateTime fetchTime = null;
FYI, when used with Spring Data JPA , requires the removal of @Id and @Type annotations from MappedSuperclass . If they are not deleted, errors below will appear. This does not change the nature of this Hibernate, BTW error.
org.springframework.data.mapping.model.MappingException: Ambiguous mapping! Annotation Id configured on field twitterUserId and one of its accessor methods in class TwitterFollowerCount! at org.springframework.data.mapping.model.AnnotationBasedPersistentProperty.populateAnnotationCache(AnnotationBasedPersistentProperty.java:111) at org.springframework.data.mapping.model.AnnotationBasedPersistentProperty.<init>(AnnotationBasedPersistentProperty.java:66) at org.springframework.data.jpa.mapping.JpaPersistentPropertyImpl.<init>(JpaPersistentPropertyImpl.java:86) at org.springframework.data.jpa.mapping.JpaMetamodelMappingContext.createPersistentProperty(JpaMetamodelMappingContext.java:67) at org.springframework.data.jpa.mapping.JpaMetamodelMappingContext.createPersistentProperty(JpaMetamodelMappingContext.java:35) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:449) at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:427) at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:607) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:295) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:257) at org.springframework.data.mapping.context.AbstractMappingContext.initialize(AbstractMappingContext.java:373) at org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension$JpaMetamodelMappingContextFactoryBean.createInstance(JpaRepositoryConfigExtension.java:216) at org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension$JpaMetamodelMappingContextFactoryBean.createInstance(JpaRepositoryConfigExtension.java:169) at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:134) at org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension$JpaMetamodelMappingContextFactoryBean.afterPropertiesSet(JpaRepositoryConfigExtension.java:230) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) ... 40 more