To create your beans, Spring first uses your class' no-argument constructor to create an instance and then uses reflection to autowire @Autowired
fields.
But your constructor
public MiniVLEDAOImplementation() {
...
// Add new student to the database
addStudentToDB(s1);
}
calls a method that uses the SessionFactory
before it has been initialized. It is therefore null
and you get a NullPointerException
when trying to call a method on it.
You cannot add the student to the database from that point. If you want to test out your class, try unit testing.