Thank you for reading my post
Hibernate version: 3.2
I have problem with loading hibernate.cfg.xml in my application.
here is the code snippet:
Code:
package learn_hiber.chapter4;
import java.io.File;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class GenerateSchema
{
public static void main(String[] args)
{
// Amended to allow a path (to the hibernate.cfg.xml) to
// be passed to the configuration.
AnnotationConfiguration cfg = ExampleConfiguration.getConfig();;
cfg.addFile(new File("learn_hiber/hibernate.cfg.xml"));
SchemaExport schemaExport = new SchemaExport(cfg);
schemaExport.create(true, true);
}
}
when i try to run this code it return
Code:
Exception in thread "main" org.hibernate.MappingException: Could not read mapping document from file: learn_hiber\hibernate.cfg.xml
at org.hibernate.cfg.Configuration.addFile(Configuration.java:297)
at learn_hiber.chapter4.GenerateSchema.main(GenerateSchema.java:17)
Caused by: java.io.FileNotFoundException: learn_hiber\hibernate.cfg.xml (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at org.hibernate.cfg.Configuration.addFile(Configuration.java:294)
... 1 more
Java Result: 1
while my directory structure is like:
src folder contains:
-learn_hiber\chapter4
-learn_hiber\hibernate.cfg.xml
-learn_hiber\log4j.properties
the chapter 4 folder contains my annotated classes source code
src is roof folder for all my source codes.
Thanks