-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: How to get DB field name from an entity's property?
PostPosted: Wed Nov 21, 2007 10:36 am 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
We need to look up the DB table and column for an arbitrary property of a mapped data object so we can validate an external data source won't be truncated.

I've browsed through some metadata and session APIs but don't see how the property metadata is represented or accessed.

Does anyone have a pointer to a solution (or better yet some code) to tell what database column each property maps to?

We are using Hibernate 3.2, btw, and most of our mappings are in .hbm files by way of xdoclet (otherwise we'd go straight to the annotations).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 11:30 pm 
Newbie

Joined: Fri Mar 30, 2007 5:23 pm
Posts: 16
Location: New York, NY
I've never tried this, but I'd check out the following methods:
Configuration.getClassMapping()
PersistentClass.getProperty()
Property.getColumnIterator()

Don't have an environment to test it, but I believe if you do something to this effect:

Code:
String columnName = myConfiguration.getClassMapping(theObj.getClass().getName()).getProperty('propertyName').getColumnIterator().next().getName()


Or something like that. Play around and you might find what you're looking for.[/url]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.