Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0
Mapping documents:
<hibernate-mapping>
<class discriminator-value="-1" table="transferrecord" name="com.mm.mw.dto.TransferRecordImpl">
<id unsaved-value="0" name="recordNumber" column="id">
<generator class="increment"/>
</id>
<discriminator type="int" column="interfaceType"/>
<property name="creationTimestamp"/>
<property name="status"/>
<property name="dlfSiteRef"/>
<property name="transmissionNumber"/>
<property name="transmissionTimestamp"/>
<property name="interfaceType" column="interfaceType" update="false" insert="false"/>
<subclass name="com.mm.mw.ExpectedReceipt" discriminator-value="2">
<property name="cofcref"/>
<property name="locationRef"/>
<property name="ticket"/>
<property name="quantity"/>
<property name="partNumber"/>
</subclass>
<subclass name="com.mm.mw.ReceiptConfirmation" discriminator-value="1">
<property name="cofcref"/>
<property name="locationRef"/>
<property name="manualInd"/>
<property name="productRef"/>
<property name="receiptRef"/>
<property name="operatorRef"/>
<property name="scanner"/>
<property name="ticket"/>
</subclass>
<subclass name="com.mm.mw..ReplenRequest" discriminator-value="0">
<property name="valid"/>
<property name="manualInd"/>
<property name="operatorRef"/>
<property name="productRef"/>
<property name="locationRef"/>
<property name="scanDate"/>
<property name="scanTime"/>
<property name="scanner"/>
<property name="stockOutInd"/>
</subclass>
</class>
</hibernate-mapping>
-------
Hi all,
i have the following problem
as you can see from mapping document, i have TransferRecordImpl class which is extended by other 3 classes, ReplenRequest, ExpReceipt and ReceiptConfirmation.
I choosed to use a discriminator to differentiate the three....
Unfortunatley, due to my usecase, the discrimnator must be a property of
my class, for the very simple reason that one usecase of my app says
'findByInterfaceType'
where the client supplies the int value of the interfaceType.. and i could look it up by using a findByInterfaceType.
i have test failing because, after inserting a TransferRecord, using a query
like findByInterfaceType(0) didnt return anything.... and after struggling i realized that mayb the problem is this
<property name="interfaceType" column="interfaceType" update="false" insert="false"/>
But i need to do a search based on the discriminator..... and i want to avoid the '
if(value =1)
then findExpreceipt
and so on..
is that possible then to use a discriminator in a query?
if not, how can i fix my problem? shall i change mapping strategy?
thanks and regards
Marco