org.hibernate.MappingException: Cannot use identity column key generation with <union-subclass> mapping
Exception in thread "main" java.lang.ExceptionInInitializerError at cn.itcast.test.Demo1.add(Demo1.java:40) at cn.itcast.test.Demo1.main(Demo1.java:14) Caused by: org.hibernate.MappingException: Cannot use identity column key generation with <union-subclass> mapping for: cn.itcast.domain.Sales at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:67) at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294) at cn.itcast.dao.HibernateUtil.<clinit>(HibernateUtil.java:20) ... 2 more
这个是在我使用union-subclass的时候出现的,不能使用identity作为主键生成策略。原因是不允许出现主键相同。