Merge branch 'HHH-5709' of https://github.com/tblachowicz/hibernate-core into tblachowicz-HHH-5709

This commit is contained in:
Steve Ebersole 2010-11-11 11:41:38 -06:00
commit 5d8c5d371b
7 changed files with 21 additions and 9 deletions

View File

@ -195,6 +195,7 @@ public class EntityBinder {
persistentClass.setAbstract( annotatedClass.isAbstract() ); persistentClass.setAbstract( annotatedClass.isAbstract() );
persistentClass.setClassName( annotatedClass.getName() ); persistentClass.setClassName( annotatedClass.getName() );
persistentClass.setNodeName( name ); persistentClass.setNodeName( name );
persistentClass.setJpaEntityName(name);
//persistentClass.setDynamic(false); //no longer needed with the Entity name refactoring? //persistentClass.setDynamic(false); //no longer needed with the Entity name refactoring?
persistentClass.setEntityName( annotatedClass.getName() ); persistentClass.setEntityName( annotatedClass.getName() );
bindDiscriminatorValue(); bindDiscriminatorValue();

View File

@ -57,6 +57,7 @@ public abstract class PersistentClass implements Serializable, Filterable, MetaA
private String proxyInterfaceName; private String proxyInterfaceName;
private String nodeName; private String nodeName;
private String jpaEntityName;
private String discriminatorValue; private String discriminatorValue;
private boolean lazy; private boolean lazy;
@ -736,6 +737,14 @@ public abstract class PersistentClass implements Serializable, Filterable, MetaA
this.nodeName = nodeName; this.nodeName = nodeName;
} }
public String getJpaEntityName() {
return jpaEntityName;
}
public void setJpaEntityName(String jpaEntityName) {
this.jpaEntityName = jpaEntityName;
}
public boolean hasPojoRepresentation() { public boolean hasPojoRepresentation() {
return getClassName()!=null; return getClassName()!=null;
} }

View File

@ -33,20 +33,20 @@ import javax.persistence.metamodel.EntityType;
public class EntityTypeImpl<X> public class EntityTypeImpl<X>
extends AbstractIdentifiableType<X> extends AbstractIdentifiableType<X>
implements EntityType<X>, Serializable { implements EntityType<X>, Serializable {
private final String className; private final String jpaEntityName;
public EntityTypeImpl( public EntityTypeImpl(
Class<X> javaType, Class<X> javaType,
AbstractIdentifiableType<? super X> superType, AbstractIdentifiableType<? super X> superType,
String className, String jpaEntityName,
boolean hasIdentifierProperty, boolean hasIdentifierProperty,
boolean isVersioned) { boolean isVersioned) {
super( javaType, superType, hasIdentifierProperty, isVersioned ); super( javaType, superType, hasIdentifierProperty, isVersioned );
this.className = className; this.jpaEntityName = jpaEntityName;
} }
public String getName() { public String getName() {
return className; return jpaEntityName;
} }
public BindableType getBindableType() { public BindableType getBindableType() {

View File

@ -94,7 +94,7 @@ public class MetamodelImpl implements Metamodel, Serializable {
EntityTypeImpl entityType = new EntityTypeImpl( EntityTypeImpl entityType = new EntityTypeImpl(
javaType, javaType,
superType, superType,
persistentClass.getClassName(), persistentClass.getJpaEntityName(),
persistentClass.hasIdentifierProperty(), persistentClass.hasIdentifierProperty(),
persistentClass.isVersioned() persistentClass.isVersioned()
); );

View File

@ -37,7 +37,7 @@ import javax.persistence.OrderColumn;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@Entity @Entity(name="org.hibernate.ejb.test.metadata.House")
public class House { public class House {
private Key key; private Key key;
private Address address; private Address address;

View File

@ -97,7 +97,7 @@ public class MetadataTest extends TestCase {
final SingularAttribute<? super Fridge, Long> id2 = fridgeType.getId( Long.class ); final SingularAttribute<? super Fridge, Long> id2 = fridgeType.getId( Long.class );
assertNotNull( id2 ); assertNotNull( id2 );
assertEquals( Fridge.class.getName(), fridgeType.getName() ); assertEquals( "Fridge", fridgeType.getName() );
assertEquals( Long.class, fridgeType.getIdType().getJavaType() ); assertEquals( Long.class, fridgeType.getIdType().getJavaType() );
assertTrue( fridgeType.hasSingleIdAttribute() ); assertTrue( fridgeType.hasSingleIdAttribute() );
assertFalse( fridgeType.hasVersionAttribute() ); assertFalse( fridgeType.hasVersionAttribute() );
@ -106,6 +106,7 @@ public class MetadataTest extends TestCase {
assertEquals( 3, fridgeType.getDeclaredAttributes().size() ); assertEquals( 3, fridgeType.getDeclaredAttributes().size() );
final EntityType<House> houseType = factory.getMetamodel().entity( House.class ); final EntityType<House> houseType = factory.getMetamodel().entity( House.class );
assertEquals( "org.hibernate.ejb.test.metadata.House", houseType.getName() );
assertTrue( houseType.hasSingleIdAttribute() ); assertTrue( houseType.hasSingleIdAttribute() );
final SingularAttribute<House, House.Key> houseId = houseType.getDeclaredId( House.Key.class ); final SingularAttribute<House, House.Key> houseId = houseType.getDeclaredId( House.Key.class );
assertNotNull( houseId ); assertNotNull( houseId );
@ -113,6 +114,7 @@ public class MetadataTest extends TestCase {
assertEquals( Attribute.PersistentAttributeType.EMBEDDED, houseId.getPersistentAttributeType() ); assertEquals( Attribute.PersistentAttributeType.EMBEDDED, houseId.getPersistentAttributeType() );
final EntityType<Person> personType = factory.getMetamodel().entity( Person.class ); final EntityType<Person> personType = factory.getMetamodel().entity( Person.class );
assertEquals( "Homo", personType.getName() );
assertFalse( personType.hasSingleIdAttribute() ); assertFalse( personType.hasSingleIdAttribute() );
final Set<SingularAttribute<? super Person,?>> ids = personType.getIdClassAttributes(); final Set<SingularAttribute<? super Person,?>> ids = personType.getIdClassAttributes();
assertNotNull( ids ); assertNotNull( ids );

View File

@ -32,7 +32,7 @@ import javax.persistence.Entity;
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@IdClass(Person.PersonPK.class) @IdClass(Person.PersonPK.class)
@Entity @Entity(name="Homo") //Person in latin ;)
public class Person { public class Person {
private String firstName; private String firstName;
private String lastName; private String lastName;