开发者

Can not load the hbm file in hiberante

I am trying to do the Hibernate tutotial from JBoss web site. Basically it is a very simple application that adds an Event to the DB.

There is an org.hibernate.tutorial.domain.Event and an Event.hbm.xml file.

The problem is that: regardless of what i am doing i am getting an org.hibernate.MappingNotFoundException resource: Event.hbm.xml not fohund, when i initialize the Configuration object. I initilize it as follows:

File hiber开发者_开发问答nateCfgFile = new File("C:/Program Files/Development/IDE/workspace/Hibernate3.6/hibernate.cfg.xml");
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            return new Configuration().configure(hibernateCfgFile).buildSessionFactory();
        }

I have tried to specify in the hibernate.cfg.xml file the full path to the hbm file but with no success.

another wierd point is that I have to specify the hibernate.cfg.xml location. with out that it would not find the file even if it is in the src folder.

Any ideas??


First of all, you should put any hibernate (or other resources) on your java classpath. Your second problem is the space in "Program Files". I find it is best to keep anything that may need to programmatically read from the file system as far away from the dreaded "Program Files" directory as possible.


Place your mapping file in the root directory next to hibernate.cfg.xml file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜