A类的Hibernate映射XML:
<class name="com.example.A" table="table_a">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="foo" table="bar"/>
<list name="bs" table="table_b">
<key column="kee">
<index column="indx">
<many-to-many column="bss" class="com.example.B"/>
</list>
</class>
我可以得到以下类A的表名:
configuration.getClassMapping(A.getName())
.getTable()
.getName();
我还可以获取属性的列名称&#34; foo&#34;如下:
Column col = (Column) configuration
.getClassMapping(clazz.getName())
.getProperty(propertyName)
.getColumnIterator().next();
col.getName();
但我不知道如何获得:
列表的表名&#34; bs&#34; //"table_b"
&#34;键的名称&#34;列表中的列&#34; bs&#34; //"kee"
&#34;索引的名称&#34;列表&#34; bs&#34; //"indx"
与B类的多对多关系的列名//"bss"
答案 0 :(得分:0)
找到问题1,2,3的解决方案:
(1)列表“bs”//“table_b”的表名
return collection.getCollectionTable().getName();
(2)列表“bs”//“kee”的“关键”列的名称
return ((Column) collection.getKey().getColumnIterator().next()).getName();
(3)列表“bs”//“indx”
的“索引”列的名称org.hibernate.mapping.List list = (org.hibernate.mapping.List) collection;
return ((Column) collection.getIndex().getColumnIterator().next()).getName();
4还没有答案。