Moved all query related stuff to ejb