-->
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.  [ 2 posts ] 
Author Message
 Post subject: Multiple mappings, Two classes with inheritance BUG?
PostPosted: Sat Apr 08, 2006 2:02 am 
Regular
Regular

Joined: Sat Jan 22, 2005 6:57 pm
Posts: 50
Location: Chicago
If you have two classes defined like so:


Code:
public class FullListing extends Listing {
      private int value2;

      public void setValue2(int value) { blah, blah }
      public int getValue2() { blah, blah }
}

public class Listing  {
      private int value;

      public void setValue(int value) { blah, blah }
      public int getValue() { blah, blah }
}


And you have two mapping files, FullListing.hbm.xml and Listing.hbm.xml with BOTH mapping files pointing to the same table. Can you not do this?

When I try to do something like

Code:
       criteria = session.createCriteria(Listing.class);
       criteria.list();


I get really goofy results. For some reason, it trys to run the mappings for both the Listing and FullListing classes even though I only specified Listing.class in the createCriteria. I assume it has something to do with the fact that FullListing inherits from Listing. But I would expect only the Listing mapping to get processed, not FullListing.

Has anyone else encountered this and is this expected behavior?


Top
 Profile  
 
 Post subject: I'm so stupid
PostPosted: Sat Apr 08, 2006 2:20 am 
Regular
Regular

Joined: Sat Jan 22, 2005 6:57 pm
Posts: 50
Location: Chicago
I found the solution.

In the Listing.hbm.xml file, my superclass, I put

Code:
polymorphism="explicit"


in the class definition. Everything works great now.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.