Using Hibernate 2.1.2
Looked at
http://forum.hibernate.org/viewtopic.ph ... ass+insert and got scared .... :-)
I have a class "Service" and it has column "SERVICE_KIND" if the value of SERVICE_KIND='operstor' I would like a new class representing this. Classic example of subclass .. .I thought ....
Doing:
<class
name="com.xyz.model.Service"
table="SERVICE"
>
<id
name="companyS"
column="COMPANY_S"
type="java.lang.String"
length="19">
<generator class="com.xyz..SurrogateKeyGenerator"/>
</id>
<discriminator column="SERVICE_KIND" type="java.lang.String"/>
<property
name="companyName"
column="COMPANY_NAME"
type="java.lang.String"
length="80"
/>
<property
name="serviceKind"
column="SERVICE_KIND"
type="java.lang.String"
length="40"
/>
<!-- associations -->
<!-- subclasses -->
<subclass
name="com.xyz..model.Operator"
discriminator-value="operator">
/>
</subclass>
</class>
Gives an error alla "net.sf.hibernate.MappingException: Repeated column in mapping for class com.xyz.model.Operator should be mapped with insert="false" and update="flase": SERVICE_KIND.
Hmm -- I cannot set insert/update = flase in the SERVICE_KIND property since teh app will add new rows to "Service". Than I tought just giving the subclass a "dummy" extra property like
<property
name="serviceKind2"
column="SERVICE_KIND"
type="java.lang.String"
length="40"
insert="false"
update="false" />
giving the same error.
Am I doing somehing terrible stuoid wrong here ? One naive solution is of course to copy the whole mapping file for "Service", call it "Operator" and add a where="SERVICE_KIND='operator'" in the class block - but than this new class knows nothing of that it actual is a "Service" ... so I really would like to get the subclass to work for this.
Thanx for a great prodct by the way. Even if I am frustrated now - my experience with Hibernate is positive.
B