views:

36

answers:

2

Hi, I am trying to load some info from the database asynchronously.

I have a class A that has a relation One to One with ClassB.

What I do, is getting count of class A in the database then load limited number of class A

So Hibernate runs 3 queries: first to get count, second to get class A, third to load class B, mapped in class A.

I am running it asynch using a Timer like this:

 Timer timer = new Timer(true);
 // add the task to the timer
 timer.schedule(task, 1);

the task.run calls the loading method

If I am not using the timer, test works ok. If I am using it, Hibernate throws a TableNotFound Exception for the third query

any idea, what's the problem?

+1  A: 

Is your timer using the same SessionFactory? Your SessionFactory may not be configured with your hibernate.cfg.xml information.

Malaxeur
A: 

Thanks for ur replies.

After checking stack trace, I found hibernate mapping was having a problem with some class, the class has @IndexColumn with name "order" which is a keyword on SQL, that prevents table creation.

I don't know why it works w/out timer, and error discovered w/ timer.

After renaming the IndexColumn, test works ok

Noura