Hello,
i have this readonly property mapping i want to convert to annotation.
Code:
<map name="privateManagers" table="RH_EMP_FCT_GROUP_LINK" cascade="lock,merge">
<key column="EMP_ID"/>
<map-key formula="(select grp.FCT_GROUP_KEY from RH_EMP_FCT_GROUP grp where grp.FCT_GROUP_ID=FCT_GROUP_ID)" type="string"/>
<many-to-many column="FCT_ID" class="be.rmi.intranet.db.users.Function" />
</map>
So far i have the following code:
Code:
@ManyToMany(fetch=FetchType.LAZY)
@Formula(value="(select grp.FCT_GROUP_KEY from RH_EMP_FCT_GROUP grp where grp.FCT_GROUP_ID=FCT_GROUP_ID)")
@JoinTable(name = "RH_EMP_FCT_GROUP_LINK", joinColumns = {@JoinColumn(name = "EMP_ID")}, inverseJoinColumns={@JoinColumn(name="FCT_ID") })
protected Map<String, Function> getPrivateManagers() {
but (see ddl below) it doesn't seem to use the formula as a map key, it instead create a new column, name "mapkey" and use it as key.
Code:
112 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaExport - create table RH_EMP_FCT_GROUP_LINK (LINK_ID bigint not null, emp_id bigint not null, fct_id bigint not null, fct_group_id bigint not null, mapkey varchar(255), primary key (EMP_ID, FCT_GROUP_ID))
I also tried
Code:
@MapKey(columns={@Formula(value="(select grp.FCT_GROUP_KEY from RH_EMP_FCT_GROUP grp where grp.FCT_GROUP_ID=FCT_GROUP_ID)")})
because, according to javadoc
Quote:
Formula. To be used as a replacement for @Column in most places The formula has to be a valid SQL fragment
However, my ide tells me "Can not convert from Formula to Column".
So how do i convert <map-key formula="..."/> to annotations?