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 ...