Kazza Summers

Greenhorn
+ Follow
since May 30, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kazza Summers

Hi,

If anyone could help me with this, it would be great. This is the output Im getting when I try and run my project. Im getting the same thing for all classes I have mapping files for?

Thanks Karry
This is the line of code it cant get past:

Session session = HibernateUtil.getSessionFactory().getCurrentSession();

so I cant even get to the part where i can load the object.
Not sure if this will help but here is the HibernateUtil class:
public class HibernateUtil {

private static final SessionFactory sessionFactory;

static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}

public static SessionFactory getSessionFactory() {
return sessionFactory;
}

}


It is screwing up on the try catch block and throwin the exception.
Not sure I understand what you mean. Skill is just a normal object, it is only used by the Routine list. A skill object gets created and then added to Routine's list.
The DTD and all that top stuff is exactly the same in Skill as it is in Routine.
Plus the Routine.hbm.xml is in the same folder as Skill.hbm.xml and they are both being added to the bin folder with the class files when project is built. Routine is being mapped without a problem.
Yeah, I have only the default package and then seperate folders inside this. I got started on the project before I really understood the IDE enough to think about packages.

Originally posted by Paul Sturrock:
Hmm. If both these things are true you won't see this error. Best to double check I think. Look for spelling mistakes in your mapping files, make sure the hbm.xml files are in the packages you expect them to be and they are packaged with your classes correctly.

Also remember, your SessionFactory must be configured somewhere. If you are using hibernate.cfg.xml to do this every mapping file must by included. If your mapping files (and classes) are in the default package the two lines your posted should be fine.



I have checked and checked for spelling mistakes or any little extra things. Im configuring it with the hibernate.cfg.xml and all mapping files are included. Could it be anything to do with this:
<list name="skills" cascade="all-delete-orphans">
<key column="routine_id" not-null="true"/>
<list-index column="skill_index"/>
<one-to-many class="Skill"/>
</list>
This is in the Routine.hbm.xml to represent my list of skills. Do I need anything in Skill.hbm to match this. I want it to be unidirectional.

Originally posted by Paul Sturrock:
Is Skill.hbm.xml on the classpath? Is it configured in hibernate.cfg.xml?



Yeah its in the same path as the Routine.hbm.xml and the java files so has to be on classpath. By configured in the hibernate.cfg.xml do you jut mean the file is added at the bottom, like:
<mapping resource="Routine.hbm.xml"/>
<mapping resource="Skill.hbm.xml"/>
or is there something else I need to add?
Hi guys,

Im fairly new to Hibernate so will not be surprised if this problem is the result of something stupid I have done, and hopefully really easy to fix.

I have two tables Routine and Skill, and Routine has a List of skills. When I try to get the current session, it maps Routine fine and then stops at Skill, saying it could not read mapping from resource: Skill.hbm.xml.

If you want me to post any code let me know.
Any suggestions or help would be greatly appreciated.

Thanks Kazza