hello,
I would like to use the @PostLoad annotation on a method so that this method is called after a class is loaded from persistence (to initialize fields that have been added and thus are null).
Unfortunately, when I annotate a method (in class Project) with @PostLoad:
@PostLoad public void debug() { System.exit(1); } this method never gets called (the application doesn't exit).
My application uses a dynamic AnnotationConfiguration, so that each project gets its own HSQLDB-Database in projects/<name>/projectdb.*:
public static SessionFactory createSessionFactory(String project_name) { String dbfile = String.format("%s/projectdb", getPath(project_name).getPath()); return new AnnotationConfiguration().configure(new File("hibernate.cfg.xml")) .setProperty("hibernate.connection.url", String.format("jdbc:hsqldb:file:%s;shutdown=true", dbfile)) .buildSessionFactory(); }
A project is persisted like this: Transaction tx = session.beginTransaction(); session.saveOrUpdate(prj); tx.commit();
The session is opened once per Project for the entire Application lifetime (possible because this is a desktop application - no concurrent accesses).
Do I need to debug hibernate on source-level or does someone have another idea on what I could try?
Thanks in advance!
|