-->
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: how to stop outter query ?
PostPosted: Tue Feb 21, 2006 8:13 am 
Newbie

Joined: Tue Feb 21, 2006 7:52 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:[/b] hibernate-3.0

[b]Mapping documents:[/b]
<hibernate-mapping>
<class name="Resource" table="resource">
<id column="ResourceId" name="id" type="java.lang.Long">
<generator class="native"/>
</id>

<property column="ResourceName" length="255" name="resourcename" not-null="true" type="java.lang.String"/>

<joined-subclass name="Managedresource" table="managedresource" >
<key column="ResourceId"/>
<property column="ManagementMethodSupported" length="255" name="managementmethodsupported" not-null="true"
type="java.lang.String"/>
</joined-subclass>
</class>
</hibernate-mapping>

class Managedresource extends Resource.

I use "Table per subclass" create DB and mapping files.
when I query Resource, the sql use "outer" to find out all result include Managedresource. How can I stop to use "outer" sql? I wanna get Resource result only when I query Resource


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 11:29 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
This has got to be my most-frequently-asked question, recently :)

Hibernate is aware that all rows in Resource might be ManagedResources. Any instances of ManagedResource MUST be loaded with all columns from both tables. Polymorphism requires this: a ManagedResource with only its Resource values is not a ManagedResource. Therefore, all Resources will always be loaded with that outer join, in case any of them are ManagedResources.

If you use delegation instead of inheritance, then you can choose if you want the inner or outer join in the normal way. This would mean that ManagedResource doesn't extend Resource: instead, some Resource objects will have a ManagedResource object inside of them, and they'd delegate ManagedResource properties to that object.


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.