Announcement Announcement Module
Collapse
No announcement yet.
column not found Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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 >= :startTime AND
      UNIX_TIMESTAMP(C2303)*1000 <= :endTime ) 
    AND (i.ktag = :ktag) AND ({i.pkID} = :inventoryID)
    Now my Hibernate SQL Query I built here:
    Code:
    query = session.createSQLQuery(queryString)
       .addEntity("c", Calculation.class).addJoin("i", "c.rel_mtag");
    The sql table names are calculation and inventory and the "rel_mtag" in my addJoin path is a property in my "Calculation" Hibernate class, which links to the Hibernate class "Inventory".

    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] - <SQL Error: 0, SQLState: S0022> (session 9F
    2011-02-16 13:25:43,014 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Column 'pkID8_1_' not found.> (session 9F
    2011-02-16 13:25:43,014 INFO [getCalibrations] - <Rollback in getCali : org.hibernate.exception.SQLGrammarException: could not execute query> (session 9F


    Can you help?
    Last edited by tacco; Feb 16th, 2011, 12:26 PM.

  • #2
    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 >= :startTime AND
      UNIX_TIMESTAMP(C2303)*1000 <= :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

    Comment


    • #3
      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("startTime", startDate, Hibernate.STRING);
      And yes thats hibernate, but with SQL. I used this method:

      Code:
      	    query = session.createSQLQuery(queryString).addEntity("c", Calculation.class).addJoin("i", "c.rel_mtag");
      where the addJoin statement was a little bit of a miracle for me. didn't understand that.

      And "where 1=1" is funny. I wanted the " AND.." 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 "WHERE 1=1" 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

      Comment


      • #4
        Introduction

        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.

        Comment


        • #5
          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

          Comment

          Working...
          X