-->
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: Get table name from entity
PostPosted: Tue Jul 15, 2008 9:58 am 
Newbie

Joined: Fri Jul 11, 2008 9:37 am
Posts: 6
I have done some searching and I haven't found anything on how to do this. I want to get the table name that an entity is associated with. I thought this would be a function on the ClassMetadata, but I found no such thing. Is this even possible? I wanted to avoid having to use static final variables for the table names.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 15, 2008 1:12 pm 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
you can get that out of the Configuration used to create the SessionFactory.

this one should help.

http://www.hibernate.org/hib_docs/v3/ap ... ang.String)

Unfortunatly API Doc is a little ... ähm ... thin ;-)

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 11:40 am 
Newbie

Joined: Fri Jul 11, 2008 9:37 am
Posts: 6
I found out how to do what i was wanting to do. I didnt end up needing the table names after all. Thanks for your help. Here is what I used:

Code:
      ClassMetadata itemMetaData = HibernateUtil.getClassMetaData( Item.class );
      ClassMetadata suppMetaData = HibernateUtil.getClassMetaData( Supplier.class );
      ClassMetadata vendMetaData = HibernateUtil.getClassMetaData( Vendor.class );
      
      String suppIdentifier = vendMetaData.getIdentifierPropertyName();
      String vendIdentifier = vendMetaData.getIdentifierPropertyName();
      String[] suppPropNames = suppMetaData.getPropertyNames();
      String[] itemPropNames = itemMetaData.getPropertyNames();
[/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.