-->
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.  [ 8 posts ] 
Author Message
 Post subject: What does this exception mean?
PostPosted: Thu Aug 19, 2004 4:33 pm 
Beginner
Beginner

Joined: Tue Jul 27, 2004 2:50 pm
Posts: 23
Hi all,

Here is the code I have:

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(gov.nih.nci.caBIO.bean.Gene.class).
              addClass(gov.nih.nci.caBIO.bean.Pathway.class).
              addClass(gov.nih.nci.caBIO.bean.ExpressionMeasurement.class).
              addClass(gov.nih.nci.caBIO.bean.ArrayReporterMap.class).
              addClass(gov.nih.nci.caBIO.bean.GeneReporter.class).
              addClass(gov.nih.nci.caBIO.bean.PathwayGene.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 ";

        net.sf.hibernate.Query query = null;

        query = session.createQuery(sqlStr);

        java.util.List c = query.list();




When I run it, I get the following exception. Any ideas as to why? It is weird that the sql statement getting printed out has gov.nih.nci.caBIO.bean.Gene g instead of Gene g!

Code:

gov.nih.nci.common.persistence.PersistenceException: Error getting objects; nest
ed exception is:
        net.sf.hibernate.QueryException: in expected: p [select p.* from BIO_Pat
hways p, gov.nih.nci.caBIO.bean.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 g
r.gene_id = g.gene_id and gr.reporter_id = r.reporter_id ]
net.sf.hibernate.QueryException: in expected: p [select p.* from BIO_Pathways p,
gov.nih.nci.caBIO.bean.Gene g, Reporter r, Pathway_Gene_Object pg, Gene_Reporte
r gr where pg.pathway_id = p.pathway_id and pg.gene_id = g.gene_id and gr.gene_i
d = g.gene_id and gr.reporter_id = r.reporter_id ]
        at net.sf.hibernate.hql.FromParser.token(FromParser.java:102)
        at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
        at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.ja
va:123)
        at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149
)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138
)
        at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.
java:293)
        at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1561)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1532)
        at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
        at gov.nih.nci.common.persistence.DefaultPersistenceManager.search(Unkno
wn Source)
        at gov.nih.nci.common.manager.DefaultObjectManager.search(Unknown Source
)
        at gov.nih.nci.common.remote.rmi.RMIObjectManagerRemote.search(Unknown S
ource)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
        at sun.rmi.transport.Transport$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Unknown Source)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour
ce)


Any help would be appreciated,
Payam.
[/code]


Top
 Profile  
 
 Post subject: Re: What does this exception mean?
PostPosted: Thu Aug 19, 2004 4:35 pm 
Beginner
Beginner

Joined: Tue Jul 27, 2004 2:50 pm
Posts: 23
Hi all,

Here is the code I have:

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(gov.nih.nci.caBIO.bean.Gene.class).
              addClass(gov.nih.nci.caBIO.bean.Pathway.class).
              addClass(gov.nih.nci.caBIO.bean.ExpressionMeasurement.class).
              addClass(gov.nih.nci.caBIO.bean.ArrayReporterMap.class).
              addClass(gov.nih.nci.caBIO.bean.GeneReporter.class).
              addClass(gov.nih.nci.caBIO.bean.PathwayGene.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 ";

        net.sf.hibernate.Query query = null;

        query = session.createQuery(sqlStr);

        java.util.List c = query.list();




When I run it, I get the following exception. Any ideas as to why and what it means? It is weird that the sql statement getting printed out has gov.nih.nci.caBIO.bean.Gene g instead of Gene g!

Code:

gov.nih.nci.common.persistence.PersistenceException: Error getting objects; nest
ed exception is:
        net.sf.hibernate.QueryException: in expected: p [select p.* from BIO_Pat
hways p, gov.nih.nci.caBIO.bean.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 g
r.gene_id = g.gene_id and gr.reporter_id = r.reporter_id ]
net.sf.hibernate.QueryException: in expected: p [select p.* from BIO_Pathways p,
gov.nih.nci.caBIO.bean.Gene g, Reporter r, Pathway_Gene_Object pg, Gene_Reporte
r gr where pg.pathway_id = p.pathway_id and pg.gene_id = g.gene_id and gr.gene_i
d = g.gene_id and gr.reporter_id = r.reporter_id ]
        at net.sf.hibernate.hql.FromParser.token(FromParser.java:102)
        at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
        at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.ja
va:123)
        at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149
)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138
)
        at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.
java:293)
        at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1561)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1532)
        at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
        at gov.nih.nci.common.persistence.DefaultPersistenceManager.search(Unkno
wn Source)
        at gov.nih.nci.common.manager.DefaultObjectManager.search(Unknown Source
)
        at gov.nih.nci.common.remote.rmi.RMIObjectManagerRemote.search(Unknown S
ource)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
        at sun.rmi.transport.Transport$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Unknown Source)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour
ce)


Any help would be appreciated,
Payam.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 4:32 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
If you need all the BIO_Pathways object that match your where clause try to use only "select p from..." instead of "select p.* from..."


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 4:38 am 
Beginner
Beginner

Joined: Thu Aug 19, 2004 5:20 am
Posts: 25
It looks as if your SQL Statement is Incorrect, its expectice the IN keyword just after your WHERE somewhere


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 9:12 am 
Beginner
Beginner

Joined: Tue Jul 27, 2004 2:50 pm
Posts: 23
I do not think the sql is wrong. I have shorten my sql just to debug it, but the way it is right now works if queried against a database directly.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 9:15 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
Have you tryied my solution?
The error is in HQL


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 9:27 am 
Beginner
Beginner

Joined: Tue Jul 27, 2004 2:50 pm
Posts: 23
Teg, I tried your resolution as well but I got the same error.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 10:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
The problem is you are using createQuery() to run a SQL query.

You have not read the documentation about native SQL queries in Hibernate. Please don't post here again until you have read the user manual start-to-finish. TIA


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.