-->
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.  [ 4 posts ] 
Author Message
 Post subject: Creation of Tables Dynamically
PostPosted: Wed Feb 07, 2007 7:03 am 
Newbie

Joined: Wed Feb 07, 2007 6:44 am
Posts: 2
HI,

I have a strange requirement. can any one please guide me how to implement for this requirement using hibrenate.

I have a table called templates, whose columns are
1. template_id -> primary key
2. template_name -> name
3. template_table_name -> name of the table to be created
4. template_table_columns -> column and column type list in , and ; separated strings.. e.g. id,int;name,string;desc,string..

there will be records inserted (but no updates) to this table called templates. and my program must be capable enough to create table of that type in a given database.

can someone help me out of such a requirement...

Thanks
siva


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 9:38 am 
Newbie

Joined: Wed Feb 07, 2007 4:34 am
Posts: 8
Hi,

There can be two ways one can go about:

1) The data in a database can be used anyhow we can, so we can certainly generate an sql file with all the creates in it.
Manually run the sql script in another or same database.

2) I am not aware of whether hibernate provides an api to create a table
but, however we can maintain another sessionfactory to open a connection to a different database.

Thanks,
Lakshmi


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 1:30 pm 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
Hi,

You can also use this property in the hibernate configuration file (hibernate.cfg.xml)
Code:
<property name="hibernate.hbm2ddl.auto">update</property>


For more info of this property you can look at this link
http://www.hibernate.org/hib_docs/v3/re ... n-optional

Budyanto


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 12, 2007 5:13 am 
Newbie

Joined: Wed Feb 07, 2007 6:44 am
Posts: 2
We can process the data in tables to create template tables using some other way. But, I wanted the table created must be DB independent.

Is there way to create the tables dynamically during runtime.

hibernate.hbm2ddl.auto option can be used to generate SQL or to Run directly in DB.

But my question how to configure the Table Scema Dynamically so that Hibernate can generate or created tables.

thanks
siva


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