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