-->
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.  [ 8 posts ] 
Author Message
 Post subject: getAllPropertiesIterator doesn't get superclass properties
PostPosted: Tue Mar 06, 2007 3:48 pm 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
Is getAllPropertiesIterator supposed to get all parent properties, when an entity subclasses many another entity, or say something like a mapped superclass, or how about just a JavaBean?

I'd guess it should get those properties as well. The situation I have where it isn't working is with the subclass entity and superclass entity in a SINGLE_TABLE inheritance strategy. What might be the problem (if this isn't expected behavior) here?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 08, 2007 1:29 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
The pertinent code is in EntityPOJOClass:
Code:
   public Iterator getAllPropertiesIterator(PersistentClass pc) {
      List properties = new ArrayList();
      List iterators = new ArrayList();
      if ( pc.getSuperclass() == null ) {
         // only include identifier for the root class.
         if ( pc.hasIdentifierProperty() ) {
            properties.add( pc.getIdentifierProperty() );
         }
         else if ( pc.hasEmbeddedIdentifier() ) {
            Component embeddedComponent = (Component) pc.getIdentifier();
            iterators.add( embeddedComponent.getPropertyIterator() );
         }
         /*if(clazz.isVersioned() ) { // version is already in property set
            properties.add(clazz.getVersion() );
         }*/
      }

      iterators.add( properties.iterator() );
      iterators.add( pc.getPropertyIterator() );
      Iterator[] it = (Iterator[]) iterators.toArray( new Iterator[iterators.size()] );
      return new SkipBackRefPropertyIterator( new JoinedIterator( it ) );
   }


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 09, 2007 1:55 pm 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
I see, it seems only to add elements to the iterator named "properties" if there is no superclass. Rather than overriding that whole method in a messy way, is there any part of the API that gets ALL properties (i.e. all superclasses and the class itself)?

I just want to confirm that I should in fact go ahead and override this method (and that there is no method in the API that already has this functionality).

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 19, 2007 11:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no, this method should just list the properties relevant for pojo/mapping generation.

including super class properties does not make sense here.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 9:42 am 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
Here's how I've tried to get the functionality to get superclass and current class properites, but it doesn't seem to work. Could you please point me in the right direction?

(I didn't know whether to use JoinedIterator or not...I think it's doing what I thought it's doing from where it appeared in the Hibernate source code?)

[code]public Iterator getEveryPropertyIterator() {
List<Iterator> propertyList = new ArrayList<Iterator>();
propertyList.add(super.getAllPropertiesIterator());
for (POJOClass pc = super.getSuperClass(); pc != null; pc = pc.getSuperClass()) {
propertyList.add(pc.getAllPropertiesIterator());
}
for (Iterator i : propertyList) {
while (i.hasNext()) {
Property p = (Property)i.next();
}
}
return new JoinedIterator(propertyList);
}[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 5:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what does not work in that ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 5:34 pm 
Beginner
Beginner

Joined: Sat May 20, 2006 3:40 pm
Posts: 21
It still gets only the properties specified in the entity itself's source code. It doesn't reach up into every superclass to the very top like I would think it would based on the code.

Can you see anything wrong with this? (I would like to debug this but I'm running it from Ant and am still trying to figure out how to debug Ant within Eclipse...) From your response it sounds like even you think it should work, no? I'll keep going through it...

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 5:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
just looking at it doesn't make it obvious for me.

I would debug it - check out the unit tests in hibernatetools to get a headstart on that.

_________________
Max
Don't forget to rate


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

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.