Bonjour,
Je rencontre un problème pour définir les annotations de mon héritage multi-niveaux.
En fait, j'ai 3 entités :
- "SocieteLieuPer" qui hérite de "PersitenceEntityPer"
- "PersitenceEntityPer" qui hérite de "PersitenceEntity"
- "PersitenceEntity"
Voici le code correspondant :
PersistenceEntity
PersistenceEntityPer
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 @MappedSuperclass @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class PersistenceEntity implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @Column(name = "VERSION", nullable = false) @Version private int version;
SocieteLieuPer
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 @MappedSuperclass @Inheritance( strategy = InheritanceType.TABLE_PER_CLASS) public class PersistenceEntityPer extends PersistenceEntity implements Comparable<PersistenceEntityPer> { private static final long serialVersionUID = 1L; @Temporal(TemporalType.DATE) @Column( name = "PERIODE_DEBUT", nullable = false) private Date periodeDebut; @Temporal(TemporalType.DATE) @Column( name = "PERIODE_FIN", nullable = false) private Date periodeFin;
Au final je ne veux qu'une seule table en base de données :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 @Entity @Table( name = "dbo.GL_SOCIETE_LIEU_PER") public class SocieteLieuPer extends PersistenceEntityPer { private static final long serialVersionUID = 1L; @ManyToOne @JoinColumn( name = "GL_SOCIETE_LIEU_ID", nullable = false) private SocieteLieu societeLieu;
Malheureusement, j'ai l'erreur suivante au démarrage de mon serveur tomcat :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 create table dbo.GL_SOCIETE_LIEU_PER ( ID int identity not null, VERSION int not null, PERIODE_DEBUT date not null, PERIODE_FIN date not null, GL_SOCIETE_LIEU_ID int not null, primary key (ID) );
Comment est-ce que je peux résoudre ce problème ?...
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 42 more
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [dbo.GL_SOCIETE_LIEU_PER]
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121)
at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:191)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:889)
... 48 more
Merci d'avance pour votre aide








Répondre avec citation




Partager