Of course, such a variante works:
<class name="nl.consul.leapfrog.db.users.User" table="USER$" schema="SYS" lazy="true">
<meta attribute="implement-equals">true</meta>
<id name="userId" column="user#" unsaved-value="any" type="long">
<generator class="assigned" />
</id>
<property name="userName" column="name" type="string" length="30" not-null="true" />
<property name="password" type="string" length="30" />
</class>
NB: userId and userName exchanged and thus it turned to be not true because actually userName is indexed (yes, strangely enough (maybe I'm wrong and not) a system table doesn't have primary key)
So, now I need to refer to table through name (yeah, it's not a very good idea to refer to user# here because it has no index but if I want? :-) ) and again through property-ref. What actually leave no choice.
I see two problems:
1. Seems Hibernate assume id should be numeric, isn't?
2. Why key-many-to-one cannot have property-ref? Though maybe my theoretical knowledge is not good enough. :-) And it's a flaw to refer from a primary key to a not primary key or even to a not indexed field. ;-) But if a referred table is not large then performance shouldn't be issue, or?
|