-->
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.  [ 4 posts ] 
Author Message
 Post subject: Invalid Column Name Exception - Runs fine in TOAD
PostPosted: Fri Apr 22, 2005 6:57 pm 
Regular
Regular

Joined: Tue Nov 30, 2004 4:23 pm
Posts: 62
I get the following exception when running the query that I included in the mapping file. When I get this exception in my WebLogic log, I can take the SQL query and run it in TOAD. Any thoughts on why this keeps telling me the column name is invalid...I have verified the tables and columns with the database. I tried to test this with the alpha hibernate tool (3.0.1) but this is not working in Eclipse 3.1 M6 for me.

Thanks for the help,

-jay

Code:
[DEBUG] 2005-04-22 15:40:02,046 [ExecuteThread: '23' for queue: 'weblogic.kernel.Default'] org.
hibernate.util.JDBCExceptionReporter                                        : could not execute
query [SELECT GOL_DESCRIPTION as GOL2_0_0_, GOL_IDENTIFIED_DATE as GOL4_0_0_, GOL_RESOLVED_DAT
E as GOL5_0_0_, GOL_STATUS as GOL3_0_0_ FROM GOAL_LOG_GOL, DM_DICT_TOPIC t WHERE GOL_TASK_ID =
? AND GOL_TIMEFRAME = ? AND GOL_TOPIC_ID = t.TOPICID ORDER BY t.SEQUENCER, GOL_SEQUENCE]
java.sql.SQLException: Invalid column name
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
        at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:3057)
        at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1861)
        at oracle.jdbc.driver.OracleResultSet.getInt(OracleResultSet.java:1605)
        at org.hibernate.type.IntegerType.get(IntegerType.java:26)
        at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
        at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
        at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:693)
        at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:282)
        at org.hibernate.loader.Loader.doQuery(Loader.java:389)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208)
        at org.hibernate.loader.Loader.doList(Loader.java:1522)
        at org.hibernate.loader.Loader.list(Loader.java:1505)
        at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:103)
        at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1343)
        at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:151)
        at com.x.GoalsDAOJdbcImpl.selectGoals(GoalsDAOJdbcImpl.
java:61)
        at com.x.CarePlanDAOJdbcImpl.getLists(CarePlanDAOJdbcIm
pl.java:657)
        at com.x.CarePlanDAOJdbcImpl.selectCarePlanDocument(Car
ePlanDAOJdbcImpl.java:238)
        at com.x.CorrespondenceSessionEJB.getCarePlan(Correspon
denceSessionEJB.java:79)
        at com.x.CorrespondenceSession_m5hsub_EOImpl.getCarePla
n(CorrespondenceSession_m5hsub_EOImpl.java:97)
        at com.x.CarePlanFormAction.execute(CarePlanFormAction.
java:84)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java
:421)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImp
l.java:1006)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
        at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppSer
vletContext.java:6718)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:3
21)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
        at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.ja
va:3764)
        at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
[WARN] 2005-04-22 15:40:02,046 [ExecuteThread: '23' for queue: 'weblogic.kernel.Default'] org.h
ibernate.util.JDBCExceptionReporter                                        : SQL Error: 17006,
SQLState: null
[ERROR] 2005-04-22 15:40:02,046 [ExecuteThread: '23' for queue: 'weblogic.kernel.Default'] org.
hibernate.util.JDBCExceptionReporter                                        : Invalid column na
me


I have the following mapping file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="com.xGoalsTO">
        <id name="id">
            <generator class="increment"/>
        </id>
        <property name="description" type="string" column="GOL_DESCRIPTION"/>
        <property name="outcome" type="string" column="GOL_STATUS"/>
        <property name="dateIdentified" type="date" column="GOL_IDENTIFIED_DATE"/>
        <property name="dateMet" type="date" column="GOL_RESOLVED_DATE"/>

    </class>

    <sql-query name="selectGoals">
        <return alias="goals" class="com.x.GoalsTO"/>
        SELECT GOL_DESCRIPTION as {goals.description},
               GOL_IDENTIFIED_DATE as {goals.dateIdentified},
               GOL_RESOLVED_DATE as {goals.dateMet},
               GOL_STATUS as {goals.outcome}
        FROM GOAL_LOG_GOL, DM_DICT_TOPIC t
        WHERE GOL_TASK_ID = :taskId
        AND GOL_TIMEFRAME = :timeframe
        AND GOL_TOPIC_ID = t.TOPICID
        ORDER BY t.SEQUENCER, GOL_SEQUENCE
    </sql-query>
</hibernate-mapping>


With the following hibernate.cfg.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

        <!--  properties -->
        <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
        <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
        <property name="hibernate.connection.username">x</property>
        <property name="hibernate.connection.password">x</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@x:1531:x</property>
        <!-- property name="hibernate.connection.datasource">jdbc/x</property-->
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>

        <property name="hibernate.show_sql">true</property>

        <!--  cache settings -->
        <mapping resource="GoalsTO.hbm.xml"/>
    </session-factory>
</hibernate-configuration>


And the following POJO class:
Code:
public class GoalsTO extends BaseTO {
    //~ Instance variables -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    private Date dateIdentified;
    private Date dateMet;
    private Integer id;
    private String description;
    private String outcome;

    //~ Constructors -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    /**
     * Default Constructor
     */
    public GoalsTO() {
    }

    //~ Methods ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    /**
     * Mutators
     */
    public void setDateIdentified(Date dateIdentified) {
        this.dateIdentified = dateIdentified;
    }


    /**
     * Accessors
     */
    public Date getDateIdentified() {
        return dateIdentified;
    }


    /**
     * @param dateMet param
     */
    public void setDateMet(Date dateMet) {
        this.dateMet = dateMet;
    }


    /**
     * @return returned
     */
    public Date getDateMet() {
        return dateMet;
    }


    /**
     * @param description param
     */
    public void setDescription(String description) {
        this.description = description;
    }


    /**
     * @return returned
     */
    public String getDescription() {
        return description;
    }


    /**
     * @param id param
     */
    public void setId(Integer id) {
        this.id = id;
    }


    /**
     * @return returned
     */
    public Integer getId() {
        return id;
    }


    /**
     * @param outcome param
     */
    public void setOutcome(String outcome) {
        this.outcome = outcome;
    }


    /**
     * @return returned
     */
    public String getOutcome() {
        return outcome;
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 23, 2005 6:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you havent selected the id in your sql query. Hbernate tries to get it from the resultset and since you havent selected it you get a column not found.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 23, 2005 11:37 am 
Regular
Regular

Joined: Tue Nov 30, 2004 4:23 pm
Posts: 62
Quick question, my table does not have id related column in it...but it appears in the mapping dtd that id element is required. When a table does not have a specific id to identify it, how would I use the id element in my sql? Would this be where I would use a composite id?

Thank you very much for your help!

-jay


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 23, 2005 11:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes.

_________________
Max
Don't forget to rate


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