-->
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.  [ 1 post ] 
Author Message
 Post subject: get table from mapped class
PostPosted: Wed Oct 27, 2010 10:45 am 
Newbie

Joined: Fri Sep 07, 2007 12:20 pm
Posts: 9
Hi,

I want to get the name of table of a mapped class without using the way over configuration, I mean without this way:

Code:
Configuration cfg = new Configuration().configure();   
Mappings m=cfg.createMappings();
System.out.println(">> class: "+m.getClass(className));
System.out.println("User table :: "+m.getClass("User").getTable());


I have a project based on seam running in JBoss, we mix in the entities Annotation and hbm.xml.

- If somebody know a way to access the configuration in seam over EntityManager this will be perhaps the way.

- If not, is There any way over EntityManager some thing like this:

Code:
Session session = (Session) getEntityManager().getDelegate();
   ClassMetadata hibernateMetadata = session.getSessionFactory().getClassMetadata(entityClass);
       if (hibernateMetadata instanceof AbstractEntityPersister){
               AbstractEntityPersister persister = (AbstractEntityPersister) hibernateMetadata;
               persister.getTableName();
     }



Here I can get just the name of table, Know some body how can I get the table Object.

Thanks for your help.

Radouane el Marjani


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

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.