HHH-7761 @IdClass not working on mapped superclasses

This commit is contained in:
brmeyer 2012-11-06 14:26:46 -05:00
parent 49468d964d
commit af66aec4a1
5 changed files with 24 additions and 17 deletions

View File

@ -58,6 +58,7 @@ import org.hibernate.metamodel.spi.source.VersionAttributeSource;
/**
* @author Hardy Ferentschik
* @author Brett Meyer
*/
public class RootEntitySourceImpl extends EntitySourceImpl implements RootEntitySource {
private final RootEntityClass rootEntityClass;
@ -238,10 +239,10 @@ public class RootEntitySourceImpl extends EntitySourceImpl implements RootEntity
@Override
public Class getLookupIdClass() {
final AnnotationInstance idClassAnnotation = JandexHelper.getSingleAnnotation(
rootEntitySource.getEntityClass().getClassInfo(),
JPADotNames.ID_CLASS
);
final AnnotationInstance idClassAnnotation = (
( RootEntityClass ) rootEntitySource.getEntityClass() )
.getIdClassAnnotation();
if ( idClassAnnotation == null ) {
return null;
}
@ -253,8 +254,9 @@ public class RootEntitySourceImpl extends EntitySourceImpl implements RootEntity
@Override
public String getIdClassPropertyAccessorName() {
// TODO: retrieve property accessor name for IdClass
return null; //To change body of implemented methods use File | Settings | File Templates.
// TODO: Should we retrieve property accessor name for the ID Class?
return rootEntitySource.getEntityClass().getClassAccessType().name()
.toLowerCase();
}
@Override

View File

@ -48,6 +48,7 @@ import org.hibernate.metamodel.spi.binding.InheritanceType;
* Represents an root entity configured via annotations/orm-xml.
*
* @author Hardy Ferentschik
* @author Brett Meyer
*/
public class RootEntityClass extends EntityClass {
@ -159,6 +160,15 @@ public class RootEntityClass extends EntityClass {
return attributes;
}
public AnnotationInstance getIdClassAnnotation() {
// TODO: refactor
final List<AnnotationInstance> idClassAnnotations = findIdAnnotations(
JPADotNames.ID_CLASS
);
return ( idClassAnnotations.size() > 0 ) ? idClassAnnotations.get( 0 ) : null;
}
private IdType determineIdType() {
List<AnnotationInstance> idAnnotations = findIdAnnotations( JPADotNames.ID );

View File

@ -23,22 +23,19 @@
*/
package org.hibernate.test.annotations.id;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.id.entities.Location;
import org.hibernate.test.annotations.id.entities.Tower;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
/**
* @author Emmanuel Bernard
*/
@SuppressWarnings("unchecked")
@FailureExpectedWithNewMetamodel
public class IdClassTest extends BaseCoreFunctionalTestCase {
@Test
public void testIdClassInSuperclass() throws Exception {

View File

@ -23,22 +23,19 @@
*/
package org.hibernate.test.annotations.id.sequences;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.id.sequences.entities.Location;
import org.hibernate.test.annotations.id.sequences.entities.Tower;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
/**
* @author Emmanuel Bernard
*/
@SuppressWarnings("unchecked")
@FailureExpectedWithNewMetamodel
public class IdClassTest extends BaseCoreFunctionalTestCase {
@Test
public void testIdClassInSuperclass() throws Exception {

View File

@ -39,7 +39,6 @@ import static org.junit.Assert.assertEquals;
*
* @author <a href="mailto:stale.pedersen@jboss.org">Stale W. Pedersen</a>
*/
@FailureExpectedWithNewMetamodel
public class IdClassGeneratedValueTest extends BaseCoreFunctionalTestCase {
@Test
@SuppressWarnings({ "unchecked" })
@ -67,6 +66,7 @@ public class IdClassGeneratedValueTest extends BaseCoreFunctionalTestCase {
@Test
@SuppressWarnings({ "unchecked" })
@FailureExpectedWithNewMetamodel
public void testSingleGeneratedValue() {
Session s = openSession();
s.beginTransaction();
@ -92,6 +92,7 @@ public class IdClassGeneratedValueTest extends BaseCoreFunctionalTestCase {
@Test
@SuppressWarnings({ "unchecked" })
@FailureExpectedWithNewMetamodel
public void testMultipleGeneratedValue() {
Session s = openSession();
s.beginTransaction();