Ok... couldn't stop myself from playing some more. Here is one way to get at unique column information. I don't know if this is the best way or not, so if anyone knows of something better,
please post.
Code:
Configuration config = session.getConfiguration();
PersistentClass pc = config.getClassMapping(CLASS_CANONICAL_NAME);
Table table = pc.getTable();
Iterator<Column> columns = (Iterator<Column>) table.getColumnIterator();
while (columns.hasNext())
{
Column column = columns.next();
System.err.println(column.getName() + ": unique --> "
+ column.isUnique());
}
For my project, we store this kind of information in our own objects for extremely easy and fast lookup. I would recommend you do something like that as well... you can load things on the fly or a start time...
One other thing... i tried getting the unique keys from the table directly, but for some reason i was not getting any results. Here is the code if you want to play around with it to see what I was missing:
Code:
Iterator<UniqueKey> uKeys = (Iterator<UniqueKey>) table
.getUniqueKeyIterator();
while (uKeys.hasNext())
{
UniqueKey uKey = uKeys.next();
System.err.println(uKey.getName() + ", "
+ uKey.getClass().getCanonicalName());
}
Good luck.