Hibernate version:2.1.6
mapping: Code:
<composite-id name="comp_id" class="PTAPK">
<meta attribute="default-value">new PTAPK()</meta>
<key-property
name="finCoaCd"
column="FIN_COA_CD"
type="java.lang.String"
length="8"
>
<meta attribute="default-value">null</meta>
</key-property>
<key-many-to-one name="project" class="Project">
<meta attribute="default-value">new Project()</meta>
<column name="PROJECT_CD" />
</key-many-to-one>
<key-property
name="taskCd"
column="TASK_CD"
type="java.lang.String"
length="8"
>
<meta attribute="default-value">null</meta>
</key-property>
<key-many-to-one name="award" class="Award">
<meta attribute="default-value">new Award()</meta>
<column name="AWARD_CD"/>
</key-many-to-one>
</composite-id>
Hi,
I am trying to build a list of the properties inside a composite key, I cannot see a clear way on how to do this? I can only get as far as getColumnIterator() which does not give me the required information (actually java property/accessor name).
getConfiguration().getClassMapping(theclass).getIdentifierProperty().getColumnIterator();
Also with Column.getType(), only isComponentType seems to be true all the time, even though some columns in aforementioned composite key are references to other objects, isAssociation et al are all false:
Code:
Property idProperty = BaseInit.getConfiguration().getClassMapping(name).getIdentifierProperty();
Type idPropertyType = s.getSessionFactory().getClassMetadata(name).getIdentifierType();
if (idProperty.isComposite())
{
log.info("Found composite PK! " + idProperty.getName() + " - " + idPropertyType.getReturnedClass().getName());
Iterator ite = idProperty.getColumnIterator();
while (ite.hasNext())
{
Column col = (Column)ite.next();
if (col.getType().isAssociationType())
log.info("Found a nested association type! " + col.getName());
if (col.getType().isComponentType())
log.info("Found a nested component type! " + col.getName());
if (col.getType().isEntityType())
log.info("Found a nested entity type! " + col.getName());
if (col.getType().isPersistentCollectionType())
log.info("Found a persistent collection type! " + col.getName());
if (col.getType().isObjectType())
log.info("Found a object type! " + col.getName());
}
Thanks for any advice,
Peter