-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: using formula in map-key, using annotation
PostPosted: Tue Aug 25, 2009 10:30 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.