-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Potential issue in PojoEntityTuplizer
PostPosted: Tue Oct 21, 2008 10:23 am 
Newbie

Joined: Wed Jan 05, 2005 8:08 am
Posts: 1
The problem, I have is the following:

In a single table inheritence model, the actual implementations should be proxied by an interface.

Code:
@Entity
@Table(name="FOO")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPE",discriminatorType=DiscriminatorType.STRING)
public abstract class AbstractFoo {
...
}


Code:
@Entity
@Proxy(proxyClass=Foo.class)
@DiscriminatorValue("DEFAULT")
public class FooImpl extends AbstractFoo implements Foo {
...
}



Mapping this I get the following exception:
Code:
Caused by: org.hibernate.MappingException: proxy must be either an interface, or the class itself: com.dummy.FooImpl
   at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:121)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
   at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
   at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)


And I think there is a copy and paste error in the PojoEntityTuplizer causing this (line 120).

Code:
      if ( proxyInterface!=null && !mappedClass.equals( proxyInterface ) ) {
         if ( !proxyInterface.isInterface() ) {
            throw new MappingException(
                    "proxy must be either an interface, or the class itself: " +
                    getEntityName()
               );
         }
         proxyInterfaces.add( proxyInterface );
      }

      if ( mappedClass.isInterface() ) {
         proxyInterfaces.add( mappedClass );
      }

      Iterator iter = persistentClass.getSubclassIterator();
      while ( iter.hasNext() ) {
         Subclass subclass = ( Subclass ) iter.next();
         Class subclassProxy = subclass.getProxyInterface();
         Class subclassClass = subclass.getMappedClass();
         if ( subclassProxy!=null && !subclassClass.equals( subclassProxy ) ) {
            if ( !proxyInterface.isInterface() ) {
               throw new MappingException(
                       "proxy must be either an interface, or the class itself: " +
                       subclass.getEntityName()
               );
            }
            proxyInterfaces.add( subclassProxy );
         }
      }


I think the check on being an interface must be on the subclassProxy and not on the proxyInterface (which is in this case the abstract superclass).

Is this a bug?

Cheers
Hansa


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.