Back Forum Reply New

column not found

Hi,
I'm a newby here and have a question. I have a SQLQuery with a join and some parameters:Code:
SELECT {c.*} FROM calculation c LEFT JOIN inventory i ON c.MTAG = i.MTAG WHERE 1=1  
AND ( UNIX_TIMESTAMP(C2303)*1000 gt;= :startTime AND UNIX_TIMESTAMP(C2303)*1000 lt;= :endTime )
AND (i.ktag = :ktag) AND ({i.pkID} = :inventoryID)
Now my Hibernate SQL Query I built here:

Code:
query = session.createSQLQuery(queryString)  .addEntity(quot;cquot;, Calculation.class).addJoin(quot;iquot;, quot;c.rel_mtagquot;);
The sql table names are calculation and inventory and the quot;rel_mtagquot; in my addJoin path is a property in my quot;Calculationquot; Hibernate class, which links to the Hibernate class quot;Inventoryquot;.

But something is wrong with my clause - so here is my error message:

2011-02-16 13:25:43,013 WARN [org.hibernate.util.JDBCExceptionReporter] - lt;SQL Error: 0, SQLState: S0022gt; (session 9F
2011-02-16 13:25:43,014 ERROR [org.hibernate.util.JDBCExceptionReporter] - lt;Column 'pkID8_1_' not found.gt; (session 9F
2011-02-16 13:25:43,014 INFO [getCalibrations] - lt;Rollback in getCali : org.hibernate.exception.SQLGrammarException: could not execute querygt; (session 9FCan you  help?

I am confuse

The follow is used for Hibernate?

Code:
SELECT {c.*} FROM calculation c LEFT JOIN inventory i ON c.MTAG = i.MTAG WHERE 1=1  
AND ( UNIX_TIMESTAMP(C2303)*1000 gt;= :startTime AND UNIX_TIMESTAMP(C2303)*1000 lt;= :endTime )
AND (i.ktag = :ktag) AND ({i.pkID} = :inventoryID)
How are you sending the parameters?, you must send 4
:startTime, :endTime, :ktag and :inventoryID

BTW WHERE 1=1  ??

1) copy the complete DAO method you are using
2) copy the complete error stack trace

BTW use code tags

sorry for confusing you. I explain to you what I tried, but I already succeeded using the criteria api. so I haven't got a solution for my former try.

I sent 4 parameters in that way:

Code:     query.setParameter(quot;startTimequot;, startDate, Hibernate.STRING);
And yes thats hibernate, but with SQL. I used this method:Code:   query = session.createSQLQuery(queryString).addEntity(quot;cquot;, Calculation.class).addJoin(quot;iquot;, quot;c.rel_mtagquot;);where the addJoin statement was a little bit of a miracle for me. didn't understand that.

And quot;where 1=1quot; is funny. I wanted the quot; AND..quot; clauses to fit nicely behind the clauses FROM part. And all my WHERE conditions have been dynamically added only if the parameter was set. So I used this quot;WHERE 1=1quot; to add then easily all ..AND. That all was String concatenation and not very JAVA at all.

okay, but now I have the Criteria API. And thats fine

I am new here. Just I want start my self.My self Moris.I am from New york. .I am student of University,Currently I have doing MBA.I am regular user of internet.My hobby like a watching TV and listing English song.I am new this forum So I want great information regarding this forum.Thanks in advance.

Hi, and so I'm new here as well. Welcome to you and have a good degree and a nice time in college and forum
¥
Back Forum Reply New