-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Tables and/or view without any mapped Java classes
PostPosted: Tue Aug 17, 2004 11:20 am 
Beginner
Beginner

Joined: Tue Jul 27, 2004 2:50 pm
Posts: 23
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 12:27 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you can't query against unmapped tables or view(even with a sqlQuery).
If you really need it, do it in jdbc....

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 12:28 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Actually, it will be possible in Hibernate3 :)

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.