-->
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.  [ 3 posts ] 
Author Message
 Post subject: How can I get column name and length of table...
PostPosted: Fri Jan 28, 2005 4:02 pm 
Newbie

Joined: Fri Jan 28, 2005 3:40 pm
Posts: 1
Hello,

How can I get column name and length of table using hibernate?

My db is postgresql. I would like do this without generating specific db sql
in my java application. Is there any way of doing this using a hql query?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 28, 2005 10:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You need to access the meta data in the Configuration object.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 29, 2005 6:58 am 
Newbie

Joined: Thu Apr 01, 2004 7:47 am
Posts: 1
[code]
public int getColumnSize(Class mappedClass, String propertyName)
{
Configuration cfg= HibernateUtils.getConfig();
PersistentClass pClass= cfg.getClassMapping(mappedClass);
Property hibProp= pClass.getProperty(propertyName)
Iterator it= hibProp.getColumnIterator();
while (it.hasNext()) {
Column col= (Column) hibProp.getColumnIterator().next();
return col.getLength();
}
}
[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.