[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5835) Error/Bug getting PluralAttribute on SessionFactoyImpl using @Inheritance and @MappedSuperclass

Francisco Philip (JIRA) noreply at atlassian.com
Wed Jan 12 00:09:05 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5835?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39586#action_39586 ] 

Francisco Philip commented on HHH-5835:
---------------------------------------

ERRATA
{noformat}
@MappedSuperclass
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn( name = "dtype")
class AbstractEntity {
@CollectionOfElements
private Collection<EmbeddedEntity> nameOfCollection;
....
}

@Entity
EntityA extends  AbstractEntity{
}

@Entity
EntityB extends  AbstractEntity{
@CollectionOfElements
private Collection<EmbeddedEntity> nameOfCollection2;
}
{noformat}

> Error/Bug getting PluralAttribute on SessionFactoyImpl using @Inheritance and @MappedSuperclass
> -----------------------------------------------------------------------------------------------
>
>                 Key: HHH-5835
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5835
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.5
>         Environment: testcase java6-sun
>            Reporter: Francisco Philip
>
> Hi, I'm looking an attribute by name    root.get("nameOfCollection"), but i think that we have a limitation or bug because if the entity inheritance of this collection they don't resolve correctly the name of "role"  to call a  getCollectionPersister method of SessionFactory.
> Example
> {noformat} 
> @MappedSuperclass
> @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
> @DiscriminatorColumn( name = "dtype")
> class c{
> @CollectionOfElements
> private Collection<EmbeddedEntity> nameOfCollection;
> ....
> }
> @Entity
> EntityA extends  AbstractEntity{
> }
> @Entity
> EntityB extends  AbstractEntity{
> @CollectionOfElements
> private Collection<EmbeddedEntity> nameOfCollection2;
> }
> {noformat} 
> if I call root.get("nameOfCollection") of they cant find it because de variable role is resolved as "AbstractEntity.nameOfCollection", meantime the collectionPersisters have stored  EntityA.nameOfCollection, EntityB.nameOfCollection and EntityB.nameOfCollection2
> this is a bug?
> SessionFactoryImpl.java
> {noformat} 
> 	public CollectionPersister getCollectionPersister(String role) throws MappingException {
> 		CollectionPersister result = (CollectionPersister) collectionPersisters.get(role);
> 		if (result==null) {
> 			throw new MappingException( "Unknown collection role: " + role );
> 		}
> 		return result;
> 	}
> {noformat} 
> AbstractManagedType.java
> {noformat} 
> 	@SuppressWarnings({ "unchecked" })
> 	public Attribute<? super X, ?> getAttribute(String name) {
> 		Attribute<? super X, ?> attribute = declaredAttributes.get( name );
> 		if ( attribute == null && getSupertype() != null ) {
> 			attribute = getSupertype().getAttribute( name );
> 		}
> 		return attribute;
> 	}
> {noformat} 

-- 
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