Page 1 of 1

Problem generating table scripts

PostPosted:Thu Dec 02, 2010 9:48 am
by cinto_qq
Hi,

I have tried to follow the script in http://wiki.openkm.com/index.php/Using_ ... _databases to generate the database scripts, but is not able to do so.

I have some questions about the script:

1) Where do I place the script?
2) Where is hibernate.cfg.xml found?
3) What other jar files do I need? I have added hibernate3.jar, all the slf4j-*.jars and javaassist.jar.

Is there any other way to get the schema?

Thanks.


Cinto

Re: Problem generating table scripts

PostPosted:Thu Dec 02, 2010 11:20 pm
by pavila
Automatic table creation is not working for you?

Re: Problem generating table scripts

PostPosted:Fri Dec 03, 2010 6:40 am
by cinto_qq
Hi Pavila,

I would like to switch the database to mysql, and I am also interested in knowing the table structures.


Cinto

Re: Problem generating table scripts

PostPosted:Sun Dec 05, 2010 1:44 pm
by pavila
But, is the automatic table creation is not working for you? Yo can configure to generate the tables in MySQL if you want. I don't know why you need to generate the script, but is easy:
Code: Select all
Configuration cfg = new Configuration();
cfg.configure(new File("/path/to/hibernate.cfg.xml"));
SchemaExport se = new SchemaExport(cfg);
se.setOutputFile("/path/to/Escritorio/schema.sql");
se.setFormat(true);
se.create(false, false);

Re: Problem generating table scripts

PostPosted:Tue Dec 07, 2010 6:21 am
by cinto_qq
Hi Pavila,

I am using this code, but I keep getting errors, like cannot find "/path/to/hibernate.cfg.xml", and missing classes.

Where do I place this table creation script?


Cinto

Re: Problem generating table scripts

PostPosted:Tue Dec 21, 2010 7:47 pm
by Sether
I'd also like to be able to create the sql creation schema file, and want to know where to find the hibernate.cfg.xml file.

I haven't tried the automatic creation program, but I'd MUCH rather have a script file that I can review and execute myself than let a program go and just create objects on my database willy-nilly.

My assumption here is that hibernate.cfg.xml is the input file that's then translated into the .sql file, and I can then run the sql file against my database and create the schema.

Re: Problem generating table scripts

PostPosted:Wed Dec 22, 2010 7:07 am
by jllort
obviously if in your system there's no the file path "/path/to/hibernate.cfg.xml" you'll get that error, you must replace that path for a valid path to the hibernate.cfg.xml in your OS and same for the output file, some valid folder path to output script

Re: Problem generating table scripts

PostPosted:Wed Dec 22, 2010 7:04 pm
by Sether
I found the answer on my own. For anyone reading this in the future, the hibernate.cfg.xml file in packed inside the OpenKM.war file in the server/default/deploy directory. Essentially all the dependencies are in this war file. If you include the classes directory inside WEB-INF and all the jars in the lib directory in WEB-INF in your classpath, you should be able to compile and run the included code.