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.  [ 4 posts ] 
Author Message
 Post subject: Abstract class with subclasses (joined-subclass)
PostPosted: Fri Feb 22, 2008 3:54 am 
Newbie

Joined: Mon Feb 11, 2008 8:43 am
Posts: 3
Hello,

I have a problem with an abstact class with 2 derived classes. NHibernate tries to instanciate my abstract class, even if there are records in the joined tables corresponding to the subclasses.

If I remove the abstract, the mapping works and only objects correponding to derived classes are returned.

The mapping file looks like this :

...
<class name="ch.VibroMeter.Xms.Configuration.Xmc.XmcChannel" table="XmcChannels">
<composite-id>
<key-property name="Id" column="Id" type="Int64" />
<key-property name="Revision" column="Revision" type="Int64"/>
</composite-id>
...

<joined-subclass name="ch.VibroMeter.Xms.Configuration.Xmc.XmcSingleDynamicProcessingChannel"
table="XmcSingleDynamicProcessingChannels" lazy="false">

<key>
<column name="Id" />
<column name="Revision"/>
</key>
</joined-subclass>

<joined-subclass name="ch.VibroMeter.Xms.Configuration.Xmc.XmcSpeedProcessingChannel"
table="XmcSpeedProcessingChannels" lazy="false">

<key>
<column name="Id" />
<column name="Revision"/>
</key>

</joined-subclass>
</class>
...

The query comes from another class with a many-to-many association to the abstract class :

<set name="XmcChannelsNH" table="XmcChannelsMachinesRelations">
<key>
<column name="MachineId" />
<column name="MachineRevision" />
</key>
<many-to-many class="ch.VibroMeter.Xms.Configuration.Xmc.XmcChannel" lazy="false">
<column name="XmcChannelId" />
<column name="XmcChannelRevision" />
</many-to-many>
</set>

Thanks in advance...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 22, 2008 4:10 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
This may be a lazy loading issue.

Your base class is mapped as lazy and the collection is mapped to the base class so Nhibernate might be trying to create a proxy for the abstract base class before resolving it to the subclasses when actually hydrating the proxies.

Not sure if that's the answer, but it's an avenue for investigation.

Cheers,

Symon.

_________________
Symon Rottem
http://blog.symbiotic-development.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 22, 2008 4:29 am 
Newbie

Joined: Mon Feb 11, 2008 8:43 am
Posts: 3
Symon,

Thank you for your reply. I tried to add 'lazy="false"' to the base class, but it didn't help.

I forgot to mention that eventually, I've added the attibute 'default-lazy="false"' in the hibernate-mapping.

Cheers
Phil


Top
 Profile  
 
 Post subject: Re: Abstract class with subclasses (joined-subclass)
PostPosted: Fri Aug 28, 2009 10:20 am 
Regular
Regular

Joined: Sat Nov 19, 2005 2:46 pm
Posts: 69
Hi phgomez,

How did you solve this in the end?

Regards,

Stewart

_________________
Stewart
London, UK


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