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: How to substitute values on specific columns (joins)
PostPosted: Mon Mar 30, 2009 2:28 pm 
Newbie

Joined: Mon May 29, 2006 5:46 pm
Posts: 2
Hey guys


I am dealing with legacy data and legacy code, thus I really can't change stuff outside of new development.

Is there any way to specific substitute values for join columns? Lets say I don't have a look up table but I have hard coded constants instead.

Like type 1,2 and 3 (which are getters that return a constant)

I want to join on the getters as opposed to a database column

For example

I have the following attribute

Code:
  @ManyToOne(cascade={CascadeType.REFRESH, CascadeType.PERSIST},targetEntity=MyClass.class)
    @JoinColumns (
                {
                   @JoinColumn (name="FK1", referencedColumnName="PK1",  insertable=false,updatable=false,nullable=true),
                   @JoinColumn (name="FK2", referencedColumnName="PK2", insertable=false,updatable=false,nullable=true)
                }
               )
   public MyValueType getAssociatedValue() {
      return associatedValue;
   }


to something like (I know that JoinGetter or referencedGetterName does not exists but just want to make an example of what I am looking for).

Code:
  @ManyToOne(cascade={CascadeType.REFRESH, CascadeType.PERSIST},targetEntity=MyClass.class)
    @JoinColumns (
                {
                   @JoinColumn (name="FK1", referencedColumnName="PK1",  insertable=false,updatable=false,nullable=true),
                   @JoinGetter (name="value", referencedGetterName="PK2", insertable=false,updatable=false,nullable=true)
                }
               )
   public MyValueType getAssociatedValue() {
      return associatedValue;
   }



Is there something like this? Or do I have to get down to the HQL level myself?

thanks for any input.


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.