找不到Hibernate Table,MappingException和OssertionException



我尝试将现有的PostgreSQL数据库映射到Hibernate,并且它已经有效,而我没有将每个子类添加到Hibernate

这是超类

@Entity
@Table(name = "place", schema = "public", catalog = "dbp")
@Inheritance(strategy = InheritanceType.JOINED)
public class PlaceEntity {
    private long id;
    private String name;
    private String url;
//    private CityEntity cityById;
    private ContinentEntity continentById;
    private CountryEntity countryById;

这是子类

@Entity
@Table(name = "city", schema = "public", catalog = "dbp")
@PrimaryKeyJoinColumn(name = "cityid", referencedColumnName = "id")
public class CityEntity extends PlaceEntity{   //WHEN I ADD extends PlaceEntity , THE ERROR OCCURES
    private Long cityid;
    private Long ispartof;
  //private PlaceEntity placeByCityid;
    private CountryEntity countryByIspartof;
    private Collection<PersonEntity> peopleByCityid;
    private Collection<UniversityEntity> universitiesByCityid;

然后Intellij浏览以下例外:

INFO: HHH000270: Type registration [java.util.UUID] overrides previous :org.hibernate.type.UUIDBinaryType@63a12c68
Sep 25, 2017 6:56:11 PM org.hibernate.AssertionFailure <init>
ERROR: HHH000099: an assertion failure occurred (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: Table dbprak24.public.place not found
Sep 25, 2017 6:56:11 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop
INFO: HHH10001008: Cleaning up connection pool [jdbc:postgresql://localhost:5432/dbprak24]
java.lang.ExceptionInInitializerError
at Main.<clinit>(Main.java:22)
Caused by: org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.JoinedSubclassEntityPersister
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:112)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:128)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:297)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726)
at Main.<clinit>(Main.java:20)
Caused by: org.hibernate.AssertionFailure: Table dbprak24.public.place not found
at org.hibernate.persister.entity.AbstractEntityPersister.getTableId(AbstractEntityPersister.java:5231)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:433)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
... 7 more
Exception in thread "main" 
Process finished with exit code 1

我已经搜索了相关问题,但找不到任何解决方案。如果有人可以帮助我,我会很高兴:)

总是删除

extends PlaceEntity

它运行平稳,并映射ALS桌子,其中包括位置。

我已经在这个问题上投资了几天^^

对不起,这不是我的外语:)

晚上好伙伴

eisenbahnplatte

我遇到了相同的问题(或非常类似的问题)。

Hibernate 5.2.17. -Final Postgresql sashitance.joined。

通过从映射中删除"目录"属性来解决它。尝试替换

@Table(name = "place", schema = "public", catalog = "dbp")

@Table(name = "place", schema = "public")

希望这会有所帮助。

相关内容

  • 没有找到相关文章

最新更新