[hibernate-issues] [Hibernate-JIRA] Created: (ANN-774) Querying a @OneToOne to an entity that inherit a @MappedSuperclass, the @DiscriminatorValue isn't used

Diego Plentz (JIRA) noreply at atlassian.com
Mon Sep 15 12:41:03 EDT 2008


Querying a @OneToOne to an entity that inherit a @MappedSuperclass, the @DiscriminatorValue isn't used
------------------------------------------------------------------------------------------------------

                 Key: ANN-774
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-774
             Project: Hibernate Annotations
          Issue Type: Bug
          Components: binder
    Affects Versions: 3.4.0.GA
            Reporter: Diego Plentz
            Priority: Critical


If you have a class with a @OneToOne relation to an entity that inherit a @MappedSuperclass, and you do a query like the following, the @DiscriminatorValue isn't used if it's mapped eagerly.

Criteria c = getSession().createCriteria(Foo.class)
.createAlias("relatedOneToOne", "relatedOneToOne");

-----
@Entity
public class Foo {
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cdfoo")
	private RelatedOneToOne relatedOneToOne;
...
}

-----

@Entity
@Table(name = "bar")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
    name="cddiscriminator",
    discriminatorType=DiscriminatorType.INTEGER)
public class Father {
..
}

-----

@Entity
@DiscriminatorValue("3")
public class RelatedOneToOne extends Father {
...
}


If you let the association to load "lazyly", it works and the DiscriminatorValue is used in the generated sql.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list