-->
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: Getting referencedColumnName in metadata or mappings
PostPosted: Wed Jun 29, 2011 6:40 pm 
Newbie

Joined: Wed Jun 29, 2011 5:42 pm
Posts: 1
Hi,

I am trying to get the value of the referencedColumnName through the class metadata, mappings, or any other API.

Let's say I have two classes with a relationship that connects them:

Code:
  public class A
  ...
  @javax.persistence.Column(name = "ARTICLE_ID", insertable = false, updatable = false)
  @Basic
  public Integer getArticleId() {
    return articleId;
  }

  @ManyToOne (fetch = javax.persistence.FetchType.LAZY)
  public
  @javax.persistence.JoinColumn(name = "ARTICLE_ID", referencedColumnName = "ARTICLE_ID")
  B getBbyArticleId() {
    return bByArticleId;
  }


Code:
   public class B
   ...
  @javax.persistence.Column(name = "ARTICLE_ID", nullable = false, insertable = false, updatable = false)
  @Id
  public Integer getArticleId() {
    return articleId;
  }

  @OneToMany(mappedBy = "bbyArticleId", fetch = javax.persistence.FetchType.LAZY)
  public Set<A> getAbyArticleId() {
    return aByArticleId;
  }


I want to do something like

sessionFactory.getClassMetadata("B").getProperty("abyArticleId").getReferencedPropertyName();
returns "articleId"

and

sessionFactory.getClassMetadata("A").getProperty("bbyArticleId").getReferencedPropertyName();
returns "articleId"

If you know of a method that will return the referenced column name, "ARTICLE_ID", that will also work.

Thank you in advance,
George


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.