开发者

See if field is mapped

Is it possible to detect if a certain field of a given class has been mapped?

E.G.

I have the object;

MyObject {
   private MyOtherObject other
}

And in the mapping file;

<many-to-one name="other" class="com.mypackage.MyOtherObject" lazy="false" />

Now is it possible to detect in java, if other has been mapped? I know I can create a static class containing mapped fields etc. But I'd rather detect it on the fly. 开发者_开发百科Is that possible?


If you just want to see if the MyOtherObject is mapped, you can try to get the ClassMetadata from the SessionFactory for that class. If it's null, it's not mapped:

s.getSessionFactory().getClassMetadata(Bar.class);


use annotations instead of xml and get annotations on the fly using reflection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜