-->
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: inheritance - lazy loading problem
PostPosted: Wed May 19, 2004 6:20 am 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
I have problem with many-to-one associaton when "one" is polymorphic object. In enviroment of JBoss app server everything works ok, but when I run hibernate app directly, problem occures, that object retrieved from many-to-one associtation is instace of Instrument class, not InstrumentOption, although it sould be.

In other words:
InstrumentHistory ih = ...loading by query
ih.getInstrument()
- returns proxy that inherits from Instrument while using hibernate directly
- and returns proxy that inherits from InstrumentOption when is executed in jboss enviroment (as sar service).


I have classes:

Instrument:
Code:
/**
* @hibernate.class table="INSTRUMENT_TBL"    proxy="com.domainmodel.Instrument"
*/
public class InstrumentStatic implements java.io.Serializable {


InstrumentOption:
Code:
/**
* @hibernate.joined-subclass table="INSTRUMENT_OPTION_TBL" proxy="com.domainmodel.InstrumentOptionStatic"
* @hibernate.joined-subclass-key column="instrumentId"
*/
public class InstrumentOption extends Instrument implements java.io.Serializable {


InstrumentHistory that holds many-to-one association:
Code:
/**
* @hibernate.class table="INSTRUMENT_HISTORY_TBL" proxy="com.domainmodel.InstrumentHistory"
*/
public class InstrumentHistory implements java.io.Serializable {
    private Long instMktDtHistEntryId;
    private Long instrumentId;
    private Instrument instrument;

    /**
     * @hibernate.property
     */
    public Long getInstrumentId() {
        return instrumentId;
    }

    /**
     * @hibernate.many-to-one column="instrumentId" class="com.domainmodel.Instrument" insert="false" update="false"
     * @hibernate.column name="instrumentId"
     */
    public Instrument getInstrument() {
        return instrument;
    }

    // etc ...





Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 6:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
That sounds really strange to me - please double check you really don't have your associations messed up, are you operating on the same database in both cases?


Top
 Profile  
 
 Post subject: strange
PostPosted: Wed May 19, 2004 6:29 am 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
It strange also for me. Database is the same, code is the same, hibernate version is the same. Also with hiber8IDE it does not return appropriate instance of object, but only ancestor class - Instrument.


Top
 Profile  
 
 Post subject: In code above I have some overstrikings
PostPosted: Wed May 19, 2004 6:33 am 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
Instead of InstrumentOptionStatic should be InstrumentOption.
Simlply where ever you find string "Static" in my code example, imagine empty string instead... sorry.


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.