Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 243477 - JPA validator attempts to validate tables/columns for abstract entity classes
Summary: JPA validator attempts to validate tables/columns for abstract entity classes
Status: RESOLVED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: General (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.2 M6   Edit
Assignee: Karen Butzke CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 258691
Blocks:
  Show dependency tree
 
Reported: 2008-08-07 14:25 EDT by Leonard Theivendra CLA
Modified: 2009-03-04 09:55 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leonard Theivendra CLA 2008-08-07 14:25:29 EDT
Build ID: wtp 3.0.1 07/28

Steps To Reproduce:
Given an inheritance hierarchy like this involving two beans:

@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) 
public abstract class Notice implements Serializable 

@Entity 
public class OverdueNotice extends Notice 


When connected to a database schema which only has tables/columns matching the "OverdueNotice" bean, the JPA validator complains about not resolving tables/columns for the abstract super class "Notice"

The spec says for the TABLE_PER_CLASS strategy, tables are only expected for concrete beans so I think the validator shouldn't even attempt to resolve tables/columns for abstract entity beans?

Ref: http://java.sun.com/javaee/5/docs/api/javax/persistence/InheritanceType.html#TABLE_PER_CLASS

More information:
Comment 1 Neil Hauge CLA 2008-08-26 17:47:18 EDT
We don't correctly handle the TABLE_PER_CLASS strategy as noted.  Given that this results in invalid error message I am going to target this at 2.0.2 for now.  Depending on the complexity/risk of the fix, this may have to move to a future release.
Comment 2 Karen Butzke CLA 2008-09-02 09:31:50 EDT
I am retargeting this to the 2.1 release.  I think the changes are going to involve some api changes.  This bug needs more investigation and really needs to be a complete effort to support 'table per class' inheritance.  Currently this is not a requirement of the JPA spec and might not even be a requirement of the 2.0 spec, not sure if they have made that decision yet.

We need to look at how this affects tables, columns, secondary tables, join tables, etc on abstract entities.  Also need to handle attribute overrides in this case?  Currently you can only set attribute overrides if your superclass is a MappedSuperclass, not an abstract entity class.  I am not sure if this is an appropriate use case for attribute overrides.
Comment 3 David Williams CLA 2008-10-20 13:13:01 EDT
I've a question ... from my naive reading ... and seems comment #1 and #2 are say slightly different things. 

Is there two problems here? That we don't handle the case and also that there is an invalid error message? 

I'm wondering if there is a compromise to soften the error message (maybe make a warning?) and then later actually handle the case? Or ... am I misunderstanding? 

Thanks, 
Comment 4 Neil Hauge CLA 2008-10-20 16:56:58 EDT
(In reply to comment #3)

My comment #1 was probably a little lacking.  The problem here is unfortunately more systematic than a particular errant error message.  The errors in question here are not inheritance specific, but are really the core errors in Dali, when database metadata does not resolve with entity defaults.  So, in this case we can't easily make them go way, or downgrade them without affecting the standard use cases.  

As Karen mentions, solving this problem properly is fairly involved.  This table_per_class strategy is an uncommon one, and not actually required to be supported by a JPA implementation in JPA 1.0, so it has received less attention to date as the more common inheritance use cases.

With all of that said, our plan would be to fix this by including the model support necessary for this inheritance strategy in a release, either 2.1 or 2.2, as time is already tight for 2.1.  Let me know if a fix is needed in maintenance and we can take a another look to see if there is a reasonable way to safely prevent these problems from appearing.  
Comment 5 Neil Hauge CLA 2008-11-03 15:39:03 EST
Retargeting to 2.2 release.  This is a larger work effort that involves new functionality.  Trying to limit the number of issues that remain for 2.1 now that M3 is closing down.
Comment 6 Karen Butzke CLA 2009-03-04 09:55:35 EST
fixed in M6, completed the table-per-class inheritance support.  DB Validation no longer occurs on an abstract table-per-class entity.  Defaults for table/schema/catalog on entities are calculated based on the inheritance strategy