-->
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.  [ 5 posts ] 
Author Message
 Post subject: mapping resource question
PostPosted: Tue Jan 20, 2004 3:30 pm 
Beginner
Beginner

Joined: Thu Oct 23, 2003 1:17 pm
Posts: 44
I'm trying to run the Cat test from the docs. It works when I have my database info in the serverl.xml, but I'd rather put my info in a hibernate.properties and load it in myself.

My TestCat.java code looks like this:
Code:
        Properties prop = new Properties();
        prop.load(TestCat.class.getResourceAsStream("/resources/hibernate.properties"));

        Configuration config = new Configuration();
        config.setProperties(prop);
//        config.addInputStream(TestCat.class.getResourceAsStream("/mappings/Cat.hbm.xml"));

        SessionFactory sessionFactory = config.buildSessionFactory();
        Session session = sessionFactory.openSession();


if I uncomment the line where I'm loading in Cat.hbm.xml, and comment out the <mapping resource="Cat.hbm.xml"> in my hibernate.cfg.xml, everything works great.

If I leave them both in there, I get an error that it's a duplicate.

If I comment out the config.addInputStream one and only load it in through the xml in the hibernate.cfg.xml, I get this error:

"net.sf.hibernate.MappingException: No persister for: com.agentscape.associate.test.Cat"

How come I can't load it in from the xml? I have the folder with the "Cat.hbm.xml" in my classpath.

Any suggestions?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2004 3:33 pm 
Beginner
Beginner

Joined: Thu Oct 23, 2003 1:17 pm
Posts: 44
Hmm...I just tried using this instead:

Code:
        <mapping file="D:/development/<full path>/mappings/Cat.hbm.xml"/>


So, it works like that, so my problem must be the path that I'm using when I load in <mapping resource="Cat.hbm.xml>, right?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 9:36 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Does this work ?
Code:
<mapping resource="mappings/Cat.hbm.xml"/>

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 10:14 am 
Beginner
Beginner

Joined: Thu Oct 23, 2003 1:17 pm
Posts: 44
emmanuel wrote:
Does this work ?
Code:
<mapping resource="mappings/Cat.hbm.xml"/>


No luck.

Actually, I'm not sure what I was thinking before, b/c I can't make the one with the full path work either.

So far, the only way I've been able to make it work, is to load it in with the Java code, and not in the XML.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 10:54 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
double check where are files in your CP structure.

_________________
Emmanuel


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