-->
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.  [ 7 posts ] 
Author Message
 Post subject: How do I get a complete list of all tables
PostPosted: Thu Nov 24, 2005 10:23 am 
Newbie

Joined: Tue Sep 27, 2005 11:03 am
Posts: 6
Hibernate version: 2.1

How do I get a complete list of all tables?
I tried calling getAllClassMetaData and this doesn't return any entities that have sets to reference other ones.
My only other thought was try and copy what the export script does but I thought there must be a simpler way.

Help!?

Rob

_________________
Rob Kirkbride


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 11:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
getAllClassmetadata DOES return classmetadata for all MAPPED classes including those with associations. I will of course not return classmetadata for tables that are not mapped as classes which is the case for many-to-many mappings.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 11:23 am 
Newbie

Joined: Tue Sep 27, 2005 11:03 am
Posts: 6
Thanks for the quick reply. How do I get a list to include those as well?

_________________
Rob Kirkbride


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 12:01 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
By exploring the metadata available on a JDBC connection.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 12:34 pm 
Newbie

Joined: Tue Sep 27, 2005 11:03 am
Posts: 6
OK I've done that. I'd of preferred for hibernate to get me a list as I've now included all tables, including any outside of hibernate but's it probably not a problem.

Rob

_________________
Rob Kirkbride


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 12:41 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Code:
((org.hibernate.mapping.PersistentClass)org.hibernate.cfg.Configuration.getClassMappings().next()).getTable().getName();


Top
 Profile  
 
 Post subject: TABLE or CLASS for collections
PostPosted: Wed Jan 11, 2006 8:46 am 
Regular
Regular

Joined: Tue Nov 29, 2005 12:31 pm
Posts: 75
Hi,

Hibernate version: 3.0.5.

*** Mappings ***

<class name="package.Parent" table="PARENT_TABLE">
...

<list name="childs" lazy="false" table="CHILD_TABLE">
<key column="PARENT_ID"/>
<index type="java.lang.Long" column="POSITION"/>
<element type="java.lang.String" column="value" not-null="true"/>
</list>
...
</class>

<class name="package.Child" table="CHILD_TABLE">

*** JAVA CODE ***

Configuration cfg = ... get the cfg file that contains the mappings above.

Type = "package.Parent";
PersistentClass persistentClass = cfg.getClassMapping(type);


// how can i get the type of the child - in this case somethign should return "package.Child".

// NOTE: I cannot cfg.getClassMappings() and iterate because the input is the parent type.


Just want to know if it's possible.

Thanks.


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