Hi all,
I am trying to use hibernate to run the following query. I have mapped Gene, Reporter and BIO_Pathways to their respective Java classes. Gene_Reporter, Pathway_Gene_Object and Array_Reporter_Map_V do not have any mapped Java classes, and it would be ideal if they do not. When I run the following query using hibernate I do not get any results back. If I run the same query against the database directly, I get some records back. Could you please advise on what I have done wrong and how I can fix this?
Here is my query:
Code:
select p.* from BIO_Pathways p, Gene g, Reporter r, Pathway_Gene_Object pg, Gene_Reporter gr
where pg.pathway_id = p.pathway_id and pg.gene_id = g.gene_id and gr.gene_id = g.gene_id and
gr.reporter_id = r.reporter_id and r.reporter_id in (select arm.reporter_id from Array_Reporter_Map_V arm where arm.array_design_id = 7)
Here is my code:
Code:
Configuration config = new Configuration();
// Tell it about the classes we want mapped, taking advantage of
// the way we've named their mapping documents.
config.addClass(bean.Gene.class).
addClass(bean.Pathway.class).
addClass(bean.ExpressionMeasurement.class);
// Get the session factory we can use for persistence
SessionFactory sessionFactory = config.buildSessionFactory();
// Ask for a session using the JDBC information we've configured
Session session = sessionFactory.openSession();
sqlStr = "select p.* " +
"from BIO_Pathways p, Gene g, Reporter r, Pathway_Gene_Object pg, " +
"Gene_Reporter gr " +
"where pg.pathway_id = p.pathway_id and pg.gene_id = g.gene_id " +
"and gr.gene_id = g.gene_id and gr.reporter_id = r.reporter_id " +
"and r.reporter_id in (select arm.reporter_id from Array_Reporter_Map_V arm " +
"where arm.array_design_id = 7)";
net.sf.hibernate.Query query = null;
query = session.createSQLQuery(sqlStr, new String[]{"g", "p", "e"},
new Class[]{bean.Gene.class,
bean.Pathway.class,
bean.ExpressionMeasurement.class});
java.util.List c = query.list();
Any help would be appreciated.
Payam.