smcnamara wrote:
hi pmularien,
I may have rated too soon ;) I'd appreciate a sample that shows solving the problem posed as I'm lost in the weeds a bit. I had been iterating the table mapping which I now think is the problem as it gives me the flat view of the object hierarchy. I guess the ClassMapping is more appropriate but the javadocs are a tad light and I'm not making much progress.
TIA,
stephen
max is pointing you in the right direction, the hibernate tools are probably the main users of all of the metadata APIs and they are fairly easy to read.
That said, there's not really a straightforward way to do what you want (which is what max was indicating). If I read your goal properly, I'd state it like this: "given column X, provide the property and/or class which maps to that column".
The available options in the existing API are -
#1 Get the Table(s) and Column(s) in the schema (you have already found this)
#2 Get the ClassMapping, and the list of Properties for each class (I pointed you at the API for this). From the Property you can get the associated Column(s)
So you'll need to provide the glue between these two APIs - you'd probably iterate over the Tables and Columns (use API #1) , and use API #2 to, given a Table/Column, iterate over ALL Classes and Property objects until you find a matching Table/Column.
It's brute force, but you could do some nice caching and optimization to make it fairly speedy.
That's your only option, if you want to file an enhancement request to the core API to perform a single atomic function (max had suggested some method signatures which would potentially fit the bill), I'd suggest filing a detailed enhancement request in JIRA.
Hope that helps,
Peter