hibernate exception: invalid identifier

when doing a session.find(from RfqResponse) query I get the following error: java.sql.SQLException: ORA-00904: "ORGANIZATI1_"."LBSS": invalid identifier

here's the full error output:

testEverything(com.talisen.lbwebpo.dao.test)net.sf.hibernate.exception.SQLGrammarException: could not load: [com.talisen.lbwebpo.model.LBSSupplierCode#1404]
      at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
      at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
      at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1332)
      at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:418)
      at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2130)
      at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2000)
      at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1962)
      at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:69)
      at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:204)
      at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2218)
      at net.sf.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:315)
      at net.sf.hibernate.loader.Loader.doQuery(Loader.java:305)
      at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
      at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
      at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
      at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
      at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
      at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
      at com.talisen.lbwebpo.dao.test.testEverything(test.java:44)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at com.talisen.lbwebpo.dao.test.main(test.java:27)
Caused by: java.sql.SQLException: ORA-00904: "ORGANIZATI1_"."LBSS": invalid identifier

      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
      at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
      at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
      at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
      at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:880)
      at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2516)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2850)
      at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
      at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:537)
      at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:88)
      at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
      at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
      at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
      at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
      at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
      at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
      at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
      at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:415)

Here's what the relevant mapping files look like:


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Sun Mar 20 19:57:16 CST 2005                         -->
<hibernate-mapping package="com.talisen.lbwebpo.model">

    <class name="RfqResponse" table="RFQ_SUPPLIER_TABLE">
        <id name="rfqSupplierId" column="RFQ_SUPPLIER_ID" type="integer">
            <generator class="native"/>
        </id>
 
        <property name="supplierId" column="SUPPLIER_ID" type="integer"  not-null="true" />
        <property name="respondedDate" column="RESPONDED_DATE" type="date" />
        <property name="viewedDate" column="VIEWED_DATE" type="date" />
        <property name="supplierNumber" column="SUPPLIER_NUMBER" type="integer" not-null="true" />
        <many-to-one column="SUPPLIER_NUMBER" name="lbss" class="LBSSupplierCode" insert="false" update="false" cascade="save-update" unique="true"/>
        <many-to-one name="rfq" column="RFQ_ID" class="Rfq"  not-null="true" />
    </class>
   
</hibernate-mapping>
---------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Mon Apr 04 17:50:16 CDT 2005                         -->
<hibernate-mapping package="com.talisen.lbwebpo.model">

      <class name="LBSSupplierCode"
            table="LONG_BEACH_SITE_SUPPLIER_CODES">
            <id name="siteSupplierCode" column="SITE_SUPPLIER_CODE"
                  type="string">
                  <generator class="native" />
            </id>
            <many-to-one name="organization" column="SBMS_SUPPLIER_CODE" class="Organization"/>
      </class>

</hibernate-mapping>
----------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Tue Apr 05 10:31:28 CDT 2005                         -->
<hibernate-mapping package="com.talisen.lbwebpo.model">

      <class name="Organization" table="ORGANIZATION">
            <id name="code" column="CODE" type="string">
                  <generator class="native" />
            </id>
            <property name="orgName" column="ORG_NAME" type="string"
                  not-null="true" />
      
            <many-to-one name="lbss" property-ref="organization" class="LBSSupplierCode" unique="true"/>
      </class>

</hibernate-mapping>
---------------------------------
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 2.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<hibernate-configuration>

    <session-factory>
        <!-- properties -->
        <property name="connection.username">webpo</property>
        <property name="connection.url">jdbc:oracle:thin:@blah:1521:lgbapp</property>
        <property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
        <property name="connection.password">blah1</property>
        <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="show_sql">false</property>

        <!-- mapping files -->
        <mapping resource="com/talisen/lbwebpo/model/RfqResponse.hbm.xml"/>
        <mapping resource="com/talisen/lbwebpo/model/Rfq.hbm.xml"/>
        <mapping resource="com/talisen/lbwebpo/model/Po.hbm.xml"/>
        <mapping resource="com/talisen/lbwebpo/model/PoType.hbm.xml"/>
        <mapping resource="com/talisen/lbwebpo/model/RfqRecepient.hbm.xml"/>
        <mapping resource="com/talisen/lbwebpo/model/Organization.hbm.xml"/>
        <mapping resource="com/talisen/lbwebpo/model/LBSSupplierCode.hbm.xml"/>

    </session-factory>

</hibernate-configuration>



And here are the relevant pojos, just in case (ignore the comments - much of them are outdated):

/*
 * WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized
 * by MyEclipse Hibernate tool integration.
 *
 * Created Sun Mar 20 19:57:17 CST 2005 by MyEclipse Hibernate Tool.
 */
package com.talisen.lbwebpo.model;

import java.io.Serializable;

/**
 * A class that represents a row in the RFQ_SUPPLIER_TABLE table.
 * You can customize the behavior of this class by editing the class, {@link RfqSupplierTable()}.
 * WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized * by MyEclipse Hibernate tool integration.
 */
public class RfqResponse implements Serializable
{
    /** The cached hash code value for this instance.  Settting to 0 triggers re-calculation. */
    private int hashValue = 0;

    /** The composite primary key value. */
    private java.lang.Integer rfqSupplierId;

    /** The value of the rfqTable association. */
    private Rfq rfq;

    /** The value of the simple supplierId property. */
    private java.lang.Integer supplierId;

    /** The value of the simple supplierNumber property. */
    private java.lang.Integer supplierNumber;

    /** The value of the simple respondedDate property. */
    private java.util.Date respondedDate;

    /** The value of the simple viewedDate property. */
    private java.util.Date viewedDate;
   
    private LBSSupplierCode lbss;

      /**
       * @return Returns the lbss.
       */
      public LBSSupplierCode getLbss() {
            return lbss;
      }
      /**
       * @param lbss The lbss to set.
       */
      public void setLbss(LBSSupplierCode lbss) {
            this.lbss = lbss;
      }
    /**
     * Simple constructor of RfqResponse instances.
     */
    public RfqResponse()
    {
    }

    /**
     * Constructor of RfqResponse instances given a simple primary key.
     * @param rfqSupplierId
     */
    public RfqResponse(java.lang.Integer rfqSupplierId)
    {
        this.setRfqSupplierId(rfqSupplierId);
    }

    /**
     * Return the simple primary key value that identifies this object.
     * @return java.lang.Integer
     */
    public java.lang.Integer getRfqSupplierId()
    {
        return rfqSupplierId;
    }

    /**
     * Set the simple primary key value that identifies this object.
     * @param rfqSupplierId
     */
    public void setRfqSupplierId(java.lang.Integer rfqSupplierId)
    {
        this.hashValue = 0;
        this.rfqSupplierId = rfqSupplierId;
    }

    /**
     * Return the value of the RFQ_ID column.
     * @return RfqTable
     */
    public Rfq getRfq()
    {
        return this.rfq;
    }

    /**
     * Set the value of the RFQ_ID column.
     * @param rfqTable
     */
    public void setRfq(Rfq rfq)
    {
        this.rfq = rfq;
    }

    /**
     * Return the value of the SUPPLIER_ID column.
     * @return java.lang.Integer
     */
    public java.lang.Integer getSupplierId()
    {
        return this.supplierId;
    }

    /**
     * Set the value of the SUPPLIER_ID column.
     * @param supplierId
     */
    public void setSupplierId(java.lang.Integer supplierId)
    {
        this.supplierId = supplierId;
    }

    /**
     * Return the value of the SUPPLIER_NUMBER column.
     * @return java.lang.Integer
     */
    public java.lang.Integer getSupplierNumber()
    {
        return this.supplierNumber;
    }

    /**
     * Set the value of the SUPPLIER_NUMBER column.
     * @param supplierNumber
     */
    public void setSupplierNumber(java.lang.Integer supplierNumber)
    {
        this.supplierNumber = supplierNumber;
    }

    /**
     * Return the value of the RESPONDED_DATE column.
     * @return java.util.Date
     */
    public java.util.Date getRespondedDate()
    {
        return this.respondedDate;
    }

    /**
     * Set the value of the RESPONDED_DATE column.
     * @param respondedDate
     */
    public void setRespondedDate(java.util.Date respondedDate)
    {
        this.respondedDate = respondedDate;
    }

    /**
     * Return the value of the VIEWED_DATE column.
     * @return java.util.Date
     */
    public java.util.Date getViewedDate()
    {
        return this.viewedDate;
    }

    /**
     * Set the value of the VIEWED_DATE column.
     * @param viewedDate
     */
    public void setViewedDate(java.util.Date viewedDate)
    {
        this.viewedDate = viewedDate;
    }

    /**
     * Implementation of the equals comparison on the basis of equality of the primary key values.
     * @param rhs
     * @return boolean
     */
    public boolean equals(Object rhs)
    {
        if (rhs == null)
            return false;
        if (! (rhs instanceof RfqResponse))
            return false;
        RfqResponse that = (RfqResponse) rhs;
        if (this.getRfqSupplierId() != null && that.getRfqSupplierId() != null)
        {
            if (! this.getRfqSupplierId().equals(that.getRfqSupplierId()))
            {
                return false;
            }
        }
        return true;
    }

    /**
     * Implementation of the hashCode method conforming to the Bloch pattern with
     * the exception of array properties (these are very unlikely primary key types).
     * @return int
     */
    public int hashCode()
    {
        if (this.hashValue == 0)
        {
            int result = 17;
            int rfqSupplierIdValue = this.getRfqSupplierId() == null ? 0 : this.getRfqSupplierId().hashCode();
            result = result * 37 + rfqSupplierIdValue;
            this.hashValue = result;
        }
        return this.hashValue;
    }
}
----------------------------------------
/*
 * WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized
 * by MyEclipse Hibernate tool integration.
 *
 * Created Mon Apr 04 17:50:16 CDT 2005 by MyEclipse Hibernate Tool.
 */
package com.talisen.lbwebpo.model;

import java.io.Serializable;

/**
 * A class that represents a row in the LONG_BEACH_SITE_SUPPLIER_CODES table.
 * You can customize the behavior of this class by editing the class, {@link LBSSupplierCode()}.
 * WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized * by MyEclipse Hibernate tool integration.
 */
public class LBSSupplierCode implements Serializable
{

    /** The value of the simple sbmsSupplierCode property. */
    private java.lang.String sbmsSupplierCode;

    /** The value of the simple siteSupplierCode property. */
    private java.lang.String siteSupplierCode;
   
    private Organization organization;

      /**
       * @return Returns the organization.
       */
      public Organization getOrganization() {
            return organization;
      }
      /**
       * @param organization The organization to set.
       */
      public void setOrganization(Organization organization) {
            this.organization = organization;
      }
    /**
     * Simple constructor of LBSSupplierCode instances.
     */
    public LBSSupplierCode()
    {
    }

    /**
     * Return the value of the SBMS_SUPPLIER_CODE column.
     * @return java.lang.String
     */
    public java.lang.String getSbmsSupplierCode()
    {
        return this.sbmsSupplierCode;
    }

    /**
     * Set the value of the SBMS_SUPPLIER_CODE column.
     * @param sbmsSupplierCode
     */
    public void setSbmsSupplierCode(java.lang.String sbmsSupplierCode)
    {
        this.sbmsSupplierCode = sbmsSupplierCode;
    }

    /**
     * Return the value of the SITE_SUPPLIER_CODE column.
     * @return java.lang.String
     */
    public java.lang.String getSiteSupplierCode()
    {
        return this.siteSupplierCode;
    }

    /**
     * Set the value of the SITE_SUPPLIER_CODE column.
     * @param siteSupplierCode
     */
    public void setSiteSupplierCode(java.lang.String siteSupplierCode)
    {
        this.siteSupplierCode = siteSupplierCode;
    }
}
-----------------------------------------------
package com.talisen.lbwebpo.model;

import java.io.Serializable;

/**
 * A class that represents a row in the ORGANIZATION table.
 * You can customize the behavior of this class by editing the class, {@link Organization()}.
 * WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized * by MyEclipse Hibernate tool integration.
 */
public class Organization implements Serializable
{

    /** The value of the simple orgName property. */
    private java.lang.String orgName;

    /** The value of the simple code property. */
    private java.lang.String code;
   
    private LBSSupplierCode lbss;

      /**
       * @return Returns the lbss.
       */
      public LBSSupplierCode getLbss() {
            return lbss;
      }
      /**
       * @param lbss The lbss to set.
       */
      public void setLbss(LBSSupplierCode lbss) {
            this.lbss = lbss;
      }
    /**
     * Simple constructor of Organization instances.
     */
    public Organization()
    {
    }

    /**
     * Return the value of the ORG_NAME column.
     * @return java.lang.String
     */
    public java.lang.String getOrgName()
    {
        return this.orgName;
    }

    /**
     * Set the value of the ORG_NAME column.
     * @param orgName
     */
    public void setOrgName(java.lang.String orgName)
    {
        this.orgName = orgName;
    }

    /**
     * Return the value of the CODE column.
     * @return java.lang.String
     */
    public java.lang.String getCode()
    {
        return this.code;
    }

    /**
     * Set the value of the CODE column.
     * @param code
     */
    public void setCode(java.lang.String code)
    {
        this.code = code;
    }
}












LVL 1
aturetskyAsked:
Who is Participating?
 
aozarovCommented:
>> <many-to-one name="lbss" property-ref="organization" class="LBSSupplierCode" unique="true"/>

From: http://www.allapplabs.com/hibernate/hibernate_o_r_mapping_many_to_one_element.htm

<many-to-one
  name="propertyName"
column="column_name"
class="ClassName"
cascade="cascade_style"
fetch="join|select"
update="true|false"
insert="true|false"
property-ref="propertyNameFromAssociatedClass"
access="field|property|ClassName"
unique="true|false"
not-null="true|false"
optimistic-lock="true|false"
lazy="true|false"
entity-name="EntityName"


(7) property-ref: (optional) The name of a property of the associated class that is joined to this foreign key. If not specified, the primary key of the associated class is used.  
* Seems that this requires your Address class table needs to have a forigen key to LBSSupplierCode table.

9) unique (optional): Enable the DDL generation of a unique constraint for the foreign-key column. Also, allow this to be the target of a property-ref. This makes the association multiplicity effectively one to one.  
* see comment 7 above. if this is in effect one-to-one relation (and you don't want to have a forigen key of LBSSupplierCode in Address) then why not use one-to-one mapping.
Also, why do you have many-to-one for Address->LBSSupplierCode instead of one-to-many (which will not require a forigen key in Address).
0
 
aturetskyAuthor Commented:
Now, I know that the problem is caused by

organizati1_.lbss as lbss0_

because there is not such field as lbss in the actual database.

Rather, it's meant to be a reference to the LBSSupplierCode class, and yet hibernate seems to perceive it as a regular field instead.

Why is that and what should I do?
0
 
aturetskyAuthor Commented:
Oops, to understand my previous elaboration on my question, you need to see the following generated sql corresponding to this query:

Hibernate: select * from ( select rfqrespons0_.RFQ_SUPPLIER_ID as RFQ_SUPP1_, rfqrespons0_.SUPPLIER_ID as SUPPLIER2_, rfqrespons0_.RESPONDED_DATE as RESPONDE3_, rfqrespons0_.VIEWED_DATE as VIEWED_D4_, rfqrespons0_.SUPPLIER_NUMBER as SUPPLIER5_, rfqrespons0_.RFQ_ID as RFQ_ID from RFQ_SUPPLIER_TABLE rfqrespons0_ )
Hibernate: select lbssupplie0_.SITE_SUPPLIER_CODE as SITE_SUP1_1_, lbssupplie0_.SBMS_SUPPLIER_CODE as SBMS_SUP2_1_, organizati1_.CODE as CODE0_, organizati1_.ORG_NAME as ORG_NAME0_, organizati1_.lbss as lbss0_ from LONG_BEACH_SITE_SUPPLIER_CODES lbssupplie0_ left outer join ORGANIZATION organizati1_ on lbssupplie0_.SBMS_SUPPLIER_CODE=organizati1_.CODE where lbssupplie0_.SITE_SUPPLIER_CODE=?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
aturetskyAuthor Commented:
Thanks, I am confused a bit, though, - what Address class are your referring to?
0
 
aozarovCommented:
Oops, replace every place I said Address with Organization
0
 
aturetskyAuthor Commented:
>> why do you have many-to-one for Address->LBSSupplierCode instead of one-to-many (which will not require a forigen key in Address).

Good point.  Which got me thinking why do I need that back-pointing reference anyway, so I got rid of the lbss element in organization and everything is now working
0
 
aturetskyAuthor Commented:
Thanks
0
 
aozarovCommented:
You are welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.