我正在尝试从春季3到4更新我的项目,并在我运行我的应用程序时将其休眠3到5.
<prop key="hibernate.hbm2ddl.auto">validate</prop>
导致以下异常
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing column [EditionNewsletterNS_id] in table [Edition_SubscriptionGroup]
at org.hibernate.tool.schema.internal.SchemaValidatorImpl.validateTable(SchemaValidatorImpl.java:85)
at org.hibernate.tool.schema.internal.SchemaValidatorImpl.doValidation(SchemaValidatorImpl.java:50)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:91)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:484)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:416)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 34 more
这是我的课程
@Entity
public class Edition extends VersionedBaseEntity {
private String name;
private String emailSubject;
private String emailAddress;
//setters and getter
}
@Entity
public class EditionNewsletterNS extends Edition
{
private final Log logger = LogFactory.getLog(getClass());
private List<SubscriptionGroup> subscriptionGroups;\
public void setSubscriptionGroups(List<SubscriptionGroup>
subscriptionGroups)
{
this.subscriptionGroups = subscriptionGroups;
}
@ManyToMany(fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
public List<SubscriptionGroup> getSubscriptionGroups()
{
return subscriptionGroups;
}
}
Edition_SubscriptionGroup将edition_id作为列而不是EditionNewsletterNS_id,这实际上是一个dtype。整个项目在hibernate 3和spring 3中运行良好。 任何帮助表示赞赏!