-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Schema Validation Fails On @MappedSuperclass
PostPosted: Tue Dec 20, 2016 3:07 pm 
Newbie

Joined: Tue Dec 20, 2016 1:43 pm
Posts: 3
I have a Spring Boot project using Spring Data JPA, with the system property 'spring.jpa.hibernate.ddl-auto=validate'. I refactored some entities to extend a base class annotated with @MappedSuperclass. The application fails to startup with the following error looking for a column on this new base class as if it's an entity:

    Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing column [cde] in table [assignments]
    at org.hibernate.tool.schema.internal.SchemaValidatorImpl.validateTable(SchemaValidatorImpl.java:85) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
    at org.hibernate.tool.schema.internal.SchemaValidatorImpl.doValidation(SchemaValidatorImpl.java:50) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
    at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:91) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:475) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
    ... 31 common frames omitted

The base class:
Code:
@MappedSuperclass
public abstract class Assignment implements Serializable {

    private static final long serialVersionUID = 8822678799185722637L;

    @Column
    private String cde;

// other common fields, getters/setters, etc.
}


One of the subclasses:
Code:
@Entity
@Table(schema = "TELCOM", name = "VW_ASSIGNMENTS")
public class TelecomAssignmentView extends Assignment implements Serializable {

    private static final long serialVersionUID = -8662949007998935627L;

    @Column(name = "ACCOUNTNUMBER", insertable = false, updatable = false)
    private String accountNumber;

// other fields, getters/setters, etc.
}


Of course I can workaround this if I set the validation property to 'none', but why would Hibernate think a class annotated with @MappedSuperclass is an entity with a backing table in need of validation? Is this a bug? Thanks!


Top
 Profile  
 
 Post subject: Re: Schema Validation Fails On @MappedSuperclass
PostPosted: Mon Jan 09, 2017 5:26 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
It sounds like a bug to me because the @MappedSuperclass should not be treated as a separate table. Please write a replicating test case and open a Jira issue. Thanks.


Top
 Profile  
 
 Post subject: Re: Schema Validation Fails On @MappedSuperclass
PostPosted: Mon Jan 09, 2017 8:47 am 
Newbie

Joined: Tue Dec 20, 2016 1:43 pm
Posts: 3
vlad wrote:
It sounds like a bug to me because the @MappedSuperclass should not be treated as a separate table. Please write a replicating test case and open a Jira issue. Thanks.


Thank you, will do!


Top
 Profile  
 
 Post subject: Re: Schema Validation Fails On @MappedSuperclass
PostPosted: Thu Jan 12, 2017 11:55 am 
Newbie

Joined: Tue Dec 20, 2016 1:43 pm
Posts: 3
OliverHrdz wrote:
vlad wrote:
It sounds like a bug to me because the @MappedSuperclass should not be treated as a separate table. Please write a replicating test case and open a Jira issue. Thanks.


Thank you, will do!


Well, in creating a test case, I discovered that I was missing the @Inheritance annotation in my base class, and now the DDL validation works!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.