-->
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: Cannot get SQLQuery to work.
PostPosted: Mon Nov 13, 2006 4:32 pm 
Newbie

Joined: Sun Nov 12, 2006 9:24 pm
Posts: 5
Hi everyone,

I am wanting to do a native SQL query as my complex joins I believe are beyond what Hibernate can handle.

Here is the code I am trying to do

Code:
Query wlQuery = session.createQuery(getHQLString(parms, types));
Query sqlQuery = session.createSQLQuery("select p.* from process p", "p", HibProcess.class);


The error I get is:
"Invalid column realId0_"

realId is the first column in the process table (realId).

What am I missing from here, the column is mapped like this

Code:
<id name="realId" column="realId" type="java.lang.Long">
   <generator class="native"></generator>
</id>


What is it meaning when it says realId0_ is invalid? Is it missing from the object I am trying to bind to, do I have to specify it directly in the query? I am confused?


Top
 Profile  
 
 Post subject: Try it with show_sql=true
PostPosted: Mon Nov 13, 2006 5:22 pm 
Beginner
Beginner

Joined: Thu Nov 02, 2006 2:23 pm
Posts: 33
Take the sql that is genertaed to the db


Top
 Profile  
 
 Post subject: Getting closer
PostPosted: Mon Nov 13, 2006 5:30 pm 
Newbie

Joined: Sun Nov 12, 2006 9:24 pm
Posts: 5
I am using Hibernate 2.1.7 which may have been causing that problem as it appears the Native SQL feature is different.

I know have this as my query

Code:
        Query sqlQuery = session.createSQLQuery(
           "select " +
           "{p}.realId as {p.id} " +
         "{p}.isDeleted as {p.isDeleted} " +
         "{p}.state as {p.state} " +
         "{p}.isRoot as {p.isRoot} " +
         "{p}.description as {p.description} " +
         "{p}.startDate as {p.startDate} " +
         "{p}.endDate as {p.endDate} " +
         "{p}.accessTag as {p.accessTag} " +
         "{p}.reactorObjectId as {p.reactorObjectId} " +
         "{p}.label as {p.label} " +
           "from process {p}","p", HibProcess.class);
     


There run-time error I get is now

Code:
SQL Error: 170, SQLState: 37000
Line 1: Incorrect syntax near 'p'.


I am getting no SQL logged obviuosly, as I am getting this error.

This is exactly the same syntax as defined in the documentation here http://www.hibernate.org/hib_docs/refer ... -nativesql


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.