Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA spec: persisting discriminator values not mandatory?
JPA spec: persisting discriminator values not mandatory? [message #768125] Mon, 19 December 2011 16:11
Karsten Wutzke is currently offline Karsten WutzkeFriend
Messages: 124
Registered: July 2009
Senior Member
Hello all,

there's currently an issue in Hibernate 4 which I consider a bug. It is here:

https://hibernate.onjira.com/browse/HHH-4358

You don't necessarily have to read everything up front. The short story is that Hibernate doesn't persist discriminator values of entities involved in inheritance with an @DiscriminatorColumn.

I have a webapp to manage a number of documents (upload, delete, ...), which got mapped as this base class:

@Entity
@Table(name = "Documents")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "discriminator", discriminatorType = DiscriminatorType.STRING)
public abstract class Document implements Serializable
{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column
    protected Integer id;

    @Column(name = "file_name")
    protected String fileName;

    ...
}

Here's a concrete sub class:

@Entity
@Table(name = "ExternalDocuments")
@DiscriminatorValue(value = "external")
public class ExternalDocument extends SystemDocument
{
    ... // no additional fields
}

Any new ExternalDocument instance gets the column's default string value in the database, here 'official' (or the first value in the list of a MySQL ENUM('official', 'reference', 'curriculumvitae', 'individual', 'external')) - which is incorrect. (AFAIK EclipseLink doesn't do this!)

I cannot find anything in the JPA 2 spec about whether discriminator values have to be persisted or not. Ultimately the person I discuss the issue with in the bug report might be correct that this Hibernate JPA issue doesn't need to be fixed.

Is this true or is it just missing information in the JPA spec? If it is present, where can I find it?

Thanks
Karsten
Previous Topic:Zipped P2 Repository for Eclipselink
Next Topic:EclipseLink Cache Coordination with Oracle GoldenGate
Goto Forum:
  


Current Time: Fri Apr 26 10:37:23 GMT 2024

Powered by FUDForum. Page generated in 0.02719 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top