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.