-->
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: Generated SQL runs but hibernate returns no rows
PostPosted: Thu Mar 25, 2004 5:21 pm 
Newbie

Joined: Wed Feb 04, 2004 1:25 am
Posts: 8
Hello all,
I am having a problem w/ many-to-one mappings. I have a table that has a unique contraint to a reference table (code/id field in the table is mapped to the code/id of the reference table). The code works fine w/o the many-to-one mapping (name="definition"). But when i include it, the code throws an exception w/ "No row with the given identifier exists". When I run the generated sql (bolded) against the db, I get the requested object .

I am using hibernate 2.1 hitting db2.

thanks in advance.

here are my mapping files:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
   "hibernate-mapping-2.0.dtd">
<hibernate-mapping schema="work" package="com.pratap.hibernate.vos">

   <class name="ChangeRequestVO" table="change_request">

      <composite-id name="compId" class="ChangeRequestKey">
         <key-property name="transactionId" column="TRANSACTION_ID" type="java.lang.String" length="22" />
         <key-property name="transactionSequence" column="TRANSACTION_SEQUENCE" type="int" length="4" />
      </composite-id>
      <timestamp name="lastChgDate" column="change_request_last_chg_date" />
      <set name="locationRequests" inverse="true" lazy="true" cascade="delete">
         <key>
            <column name="transaction_id" />
            <column name="transaction_sequence" />
         </key>
         <one-to-many class="com.pratap.hibernate.vos.LocationChgReqVO" />
      </set>
      <set name="employeeRequests" inverse="false" lazy="true" cascade="delete">
         <key>
            <column name="transaction_id" />
            <column name="transaction_sequence" />
         </key>
         <one-to-many class="EmployeeChgReqVO" />
      </set>
      <set name="classCodeRequests" inverse="false" lazy="true" cascade="delete">
         <key>
            <column name="transaction_id" />
            <column name="transaction_sequence" />
         </key>
         <one-to-many class="ClassCodeChgReqVO" />
      </set>

      <property name="changeRequestCode" type="java.lang.Integer" column="CHANGE_REQUEST_CODE" not-null="true" length="2" />
      <property name="reasonRejected" type="java.lang.String" column="REASON_REJECTED" not-null="true" length="100" />
      <property name="programId" type="java.lang.String" column="PROGRAM_ID" not-null="true" length="10" />
      <property name="estCompletionDate" type="java.sql.Date" column="ESTIMATED_COMPLETION_DATE" not-null="true" length="10" />
      <property name="dateCompleted" type="java.sql.Date" column="DATE_COMPLETED" not-null="true" length="10" />

      <!-- audit fields -->
      <property name="createDate" type="java.sql.Timestamp" column="CHANGE_REQUEST_CREATE_DATE" not-null="true" length="26" />
      <property name="createUserId" type="java.lang.String" column="CHANGE_REQUEST_CREATE_USERID" not-null="true" length="20" />
      <property name="lastChgUserId" type="java.lang.String" column="CHANGE_REQUEST_LAST_CHG_USERID" not-null="true" length="20" />

      <!-- associations -->
      <many-to-one name="transaction" class="EndorsementTransactionVO" cascade="none" update="false" insert="false">
         <column name="transaction_id" />
      </many-to-one>

                             
      [b]<many-to-one name="definition" column="change_request_code" class="ChangeRequestDefVO" cascade="none" update="false" insert="false" foreign-key="change_request_code"/>[/b]


   </class>

   <class name="ChangeRequestDefVO" table="CHANGE_REQUEST_DEF">

      <id name="code" type="int" column="CHANGE_REQUEST_CODE">
         <generator class="assigned" />
      </id>
      <timestamp name="lastChgDate" column="CHG_REQ_DEF_LAST_CHG_DATE" />
      <property name="sequenceNum" type="int" column="SEQUENCE_NUMBER" not-null="true" length="2" />
      <property name="name" type="java.lang.String" column="CHANGE_REQUEST_NAME" not-null="true" length="50" />
      <property name="effectiveDate" type="java.sql.Date" column="CHG_REQ_DEF_EFFECTIVE_DATE" not-null="true" length="10" />
      <property name="expirationDate" type="java.sql.Date" column="CHG_REQ_DEF_EXPIRATION_DATE" not-null="true" length="10" />
      <property name="processType" type="char" column="PROCESS_TYPE" not-null="true" length="1" />
      <property name="description" type="java.lang.String" column="CHG_REQUEST_DEF_DESCRIPTION" not-null="true" length="400" />
      <property name="webPage" type="java.lang.String" column="WEB_PAGE" not-null="true" length="30" />
      <property name="numberDays" type="int" column="NUMBER_OF_DAYS" not-null="true" length="3" />
      <property name="programId" type="java.lang.String" column="PROGRAM_ID" not-null="true" length="10" />

      <property name="createDate" type="java.sql.Timestamp" column="CHG_REQ_DEF_CREATE_DATE" not-null="true" length="26" />
      <property name="createUserId" type="java.lang.String" column="CHG_REQ_DEF_CREATE_USERID" not-null="true" length="20" />
      <property name="lastChgUserId" type="java.lang.String" column="CHG_REQ_DEF_LAST_CHG_USERID" not-null="true" length="20" />
         
   </class>

</hibernate-mapping>





Log files:
Code:
2004-03-25 15:06:31,717 DEBUG transaction.JDBCTransaction  - current autocommit status:false
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - generated identifier: com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - saving [com.pratap.hibernate.vos.ChangeRequestVO#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,717 DEBUG engine.Cascades  - processing cascades for: com.pratap.hibernate.vos.ChangeRequestVO
2004-03-25 15:06:31,717 DEBUG engine.Cascades  - done processing cascades for: com.pratap.hibernate.vos.ChangeRequestVO
2004-03-25 15:06:31,717 DEBUG engine.Versioning  - Seeding: 2004-03-25 15:06:31.717
2004-03-25 15:06:31,717 DEBUG engine.Cascades  - processing cascades for: com.pratap.hibernate.vos.ChangeRequestVO
2004-03-25 15:06:31,717 DEBUG engine.Cascades  - done processing cascades for: com.pratap.hibernate.vos.ChangeRequestVO
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - flushing session
2004-03-25 15:06:31,717 DEBUG engine.Cascades  - processing cascades for: com.pratap.hibernate.vos.ChangeRequestVO
2004-03-25 15:06:31,717 DEBUG engine.Cascades  - done processing cascades for: com.pratap.hibernate.vos.ChangeRequestVO
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - Flushing entities and processing referenced collections
2004-03-25 15:06:31,717 DEBUG impl.WrapVisitor  - Wrapped collection in role: com.pratap.hibernate.vos.ChangeRequestVO.locationRequests
2004-03-25 15:06:31,717 DEBUG impl.WrapVisitor  - Wrapped collection in role: com.pratap.hibernate.vos.ChangeRequestVO.employeeRequests
2004-03-25 15:06:31,717 DEBUG impl.WrapVisitor  - Wrapped collection in role: com.pratap.hibernate.vos.ChangeRequestVO.classCodeRequests
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - Collection found: [com.pratap.hibernate.vos.ChangeRequestVO.locationRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]], was: [<unreferenced>]
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - Collection found: [com.pratap.hibernate.vos.ChangeRequestVO.employeeRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]], was: [<unreferenced>]
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - Collection found: [com.pratap.hibernate.vos.ChangeRequestVO.classCodeRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]], was: [<unreferenced>]
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - Processing unreferenced collections
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - Scheduling collection removes/(re)creates/updates
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - Flushed: 3 (re)creations, 0 updates, 0 removals to 3 collections
2004-03-25 15:06:31,717 DEBUG impl.Printer  - listing entities:
2004-03-25 15:06:31,717 DEBUG impl.Printer  - com.pratap.hibernate.vos.ChangeRequestVO{lastChgUserId=pkode_test, employeeRequests=[], definition=null, transaction=null, estCompletionDate=25 March 2004, lastChgDate=25 March 2004 15:06:31, reasonRejected=myreason, locationRequests=[], programId=UNKNOWN, changeRequestCode=3, classCodeRequests=[], createDate=25 March 2004 15:06:31, createUserId=pkode_test, dateCompleted=25 March 2004, compId=ChangeRequestKey{transactionSequence=0, transactionId=2koUgYNJzeyLvw9LnWwO0U}}
2004-03-25 15:06:31,717 DEBUG impl.SessionImpl  - executing flush
2004-03-25 15:06:31,717 DEBUG persister.EntityPersister  - Inserting entity: [com.pratap.hibernate.vos.ChangeRequestVO#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,717 DEBUG persister.EntityPersister  - Version: 2004-03-25 15:06:31.717
2004-03-25 15:06:31,717 DEBUG impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-03-25 15:06:31,717 DEBUG hibernate.SQL  - insert into work.change_request (change_request_last_chg_date, CHANGE_REQUEST_CODE, REASON_REJECTED, PROGRAM_ID, ESTIMATED_COMPLETION_DATE, DATE_COMPLETED, CHANGE_REQUEST_CREATE_DATE, CHANGE_REQUEST_CREATE_USERID, CHANGE_REQUEST_LAST_CHG_USERID, TRANSACTION_ID, TRANSACTION_SEQUENCE) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2004-03-25 15:06:31,717 DEBUG impl.BatcherImpl  - preparing statement
2004-03-25 15:06:31,737 DEBUG persister.EntityPersister  - Dehydrating entity: [com.pratap.hibernate.vos.ChangeRequestVO#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,737 DEBUG type.TimestampType  - binding '25 March 2004 15:06:31' to parameter: 1
2004-03-25 15:06:31,737 DEBUG type.IntegerType  - binding '3' to parameter: 2
2004-03-25 15:06:31,737 DEBUG type.StringType  - binding 'myreason' to parameter: 3
2004-03-25 15:06:31,737 DEBUG type.StringType  - binding 'UNKNOWN' to parameter: 4
2004-03-25 15:06:31,737 DEBUG type.DateType  - binding '25 March 2004' to parameter: 5
2004-03-25 15:06:31,737 DEBUG type.DateType  - binding '25 March 2004' to parameter: 6
2004-03-25 15:06:31,737 DEBUG type.TimestampType  - binding '25 March 2004 15:06:31' to parameter: 7
2004-03-25 15:06:31,737 DEBUG type.StringType  - binding 'pkode_test' to parameter: 8
2004-03-25 15:06:31,737 DEBUG type.StringType  - binding 'pkode_test' to parameter: 9
2004-03-25 15:06:31,737 DEBUG type.StringType  - binding '2koUgYNJzeyLvw9LnWwO0U' to parameter: 10
2004-03-25 15:06:31,737 DEBUG type.IntegerType  - binding '0' to parameter: 11
2004-03-25 15:06:31,767 DEBUG impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-03-25 15:06:31,767 DEBUG impl.BatcherImpl  - closing statement
2004-03-25 15:06:31,767 DEBUG collection.BasicCollectionPersister  - Inserting collection: [com.pratap.hibernate.vos.ChangeRequestVO.employeeRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,767 DEBUG collection.BasicCollectionPersister  - collection was empty
2004-03-25 15:06:31,767 DEBUG collection.BasicCollectionPersister  - Inserting collection: [com.pratap.hibernate.vos.ChangeRequestVO.classCodeRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,767 DEBUG collection.BasicCollectionPersister  - collection was empty
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - post flush
2004-03-25 15:06:31,767 DEBUG transaction.JDBCTransaction  - commit
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - flushing session
2004-03-25 15:06:31,767 DEBUG engine.Cascades  - processing cascades for: com.pratap.hibernate.vos.ChangeRequestVO
2004-03-25 15:06:31,767 DEBUG engine.Cascades  - done processing cascades for: com.pratap.hibernate.vos.ChangeRequestVO
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - Flushing entities and processing referenced collections
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - Collection found: [com.pratap.hibernate.vos.ChangeRequestVO.locationRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]], was: [com.pratap.hibernate.vos.ChangeRequestVO.locationRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - Collection found: [com.pratap.hibernate.vos.ChangeRequestVO.employeeRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]], was: [com.pratap.hibernate.vos.ChangeRequestVO.employeeRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - Collection found: [com.pratap.hibernate.vos.ChangeRequestVO.classCodeRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]], was: [com.pratap.hibernate.vos.ChangeRequestVO.classCodeRequests#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - Processing unreferenced collections
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - Scheduling collection removes/(re)creates/updates
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - Flushed: 0 (re)creations, 0 updates, 0 removals to 3 collections
2004-03-25 15:06:31,767 DEBUG impl.Printer  - listing entities:
2004-03-25 15:06:31,767 DEBUG impl.Printer  - com.pratap.hibernate.vos.ChangeRequestVO{lastChgUserId=pkode_test, employeeRequests=[], definition=null, transaction=null, estCompletionDate=25 March 2004, lastChgDate=25 March 2004 15:06:31, reasonRejected=myreason, locationRequests=[], programId=UNKNOWN, changeRequestCode=3, classCodeRequests=[], createDate=25 March 2004 15:06:31, createUserId=pkode_test, dateCompleted=25 March 2004, compId=ChangeRequestKey{transactionSequence=0, transactionId=2koUgYNJzeyLvw9LnWwO0U}}
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - executing flush
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - post flush
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - transaction completion
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - closing session
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - disconnecting session
2004-03-25 15:06:31,767 DEBUG connection.DriverManagerConnectionProvider  - returning connection to pool, pool size: 1
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - transaction completion
2004-03-25 15:06:31,767 DEBUG businessobjects.ChangeRequestBusinessObjectImpl  - [ChangeRequestBusinessObjectImpl.read()-- reading w/ key 'com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]']
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - opened session
2004-03-25 15:06:31,767 DEBUG persistence.HibernateUtil  - [successfully connected to server]
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - loading [com.pratap.hibernate.vos.ChangeRequestVO#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - attempting to resolve [com.pratap.hibernate.vos.ChangeRequestVO#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,767 DEBUG impl.SessionImpl  - object not resolved in any cache [com.pratap.hibernate.vos.ChangeRequestVO#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,767 DEBUG persister.EntityPersister  - Materializing entity: [com.pratap.hibernate.vos.ChangeRequestVO#com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]]
2004-03-25 15:06:31,777 DEBUG impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
2004-03-25 15:06:31,777 DEBUG connection.DriverManagerConnectionProvider  - total checked-out connections: 0
2004-03-25 15:06:31,777 DEBUG connection.DriverManagerConnectionProvider  - using pooled JDBC connection, pool size: 0
[b]2004-03-25 15:06:31,777 DEBUG hibernate.SQL  - select changerequ0_.TRANSACTION_ID as TRANSACT1_2_, changerequ0_.TRANSACTION_SEQUENCE as TRANSACT2_2_, changerequ0_.change_request_last_chg_date as change_r3_2_, changerequ0_.CHANGE_REQUEST_CODE as CHANGE_R4_2_, changerequ0_.REASON_REJECTED as REASON_R5_2_, changerequ0_.PROGRAM_ID as PROGRAM_ID2_, changerequ0_.ESTIMATED_COMPLETION_DATE as ESTIMATE7_2_, changerequ0_.DATE_COMPLETED as DATE_COM8_2_, changerequ0_.CHANGE_REQUEST_CREATE_DATE as CHANGE_R9_2_, changerequ0_.CHANGE_REQUEST_CREATE_USERID as CHANGE_10_2_, changerequ0_.CHANGE_REQUEST_LAST_CHG_USERID as CHANGE_11_2_, changerequ0_.transaction_id as transac12_2_, changerequ0_.change_request_code as change_13_2_, endorsemen1_.TRANSACTION_ID as TRANSACT1_0_, endorsemen1_.ENDORSE_TRAN_LAST_CHG_DATE as ENDORSE_2_0_, endorsemen1_.POLICY_NUMBER as POLICY_N3_0_, endorsemen1_.EFFECTIVE_DATE as EFFECTIV4_0_, endorsemen1_.ENDORSEMENT_NUMBER as ENDORSEM5_0_, endorsemen1_.QUOTE_NUMBER as QUOTE_NU6_0_, endorsemen1_.QUOTE_VERSION_NUMBER as QUOTE_VE7_0_, endorsemen1_.AUTO_PROCESS as AUTO_PRO8_0_, endorsemen1_.ENDORSEMENT_COMMENTS as ENDORSEM9_0_, endorsemen1_.STATUS_OF_TRANSACTION as STATUS_10_0_, endorsemen1_.DATE_SUBMITTED as DATE_SU11_0_, endorsemen1_.RETURN_PREMIUM as RETURN_12_0_, endorsemen1_.SUBMITTED_BY as SUBMITT13_0_, endorsemen1_.AGENCY_CODE as AGENCY_14_0_, endorsemen1_.DATA_SOURCE as DATA_SO15_0_, endorsemen1_.POSTED_BY_PROGRAM as POSTED_16_0_, endorsemen1_.POSTED_BY_TIMESTAMP as POSTED_17_0_, endorsemen1_.AGENT_EMAIL as AGENT_E18_0_, endorsemen1_.ENDORSE_TRAN_EFFECTIVE_DATE as ENDORSE19_0_, endorsemen1_.AGENT_COMMENTS as AGENT_C20_0_, endorsemen1_.OTHER_STATES_INDICATOR as OTHER_S21_0_, endorsemen1_.UNDERWRITER_TYPE as UNDERWR22_0_, endorsemen1_.BRANCH_CODE as BRANCH_23_0_, endorsemen1_.UNDERWRITER_TEAM as UNDERWR24_0_, endorsemen1_.UNDERWRITER_CODE as UNDERWR25_0_, endorsemen1_.ENDORSE_TRAN_CREATE_DATE as ENDORSE26_0_, endorsemen1_.ENDORSE_TRAN_CREATE_USERID as ENDORSE27_0_, endorsemen1_.ENDORSE_TRAN_LAST_CHG_USERID as ENDORSE28_0_, changerequ2_.CHANGE_REQUEST_CODE as CHANGE_R1_1_, changerequ2_.CHG_REQ_DEF_LAST_CHG_DATE as CHG_REQ_2_1_, changerequ2_.SEQUENCE_NUMBER as SEQUENCE3_1_, changerequ2_.CHANGE_REQUEST_NAME as CHANGE_R4_1_, changerequ2_.CHG_REQ_DEF_EFFECTIVE_DATE as CHG_REQ_5_1_, changerequ2_.CHG_REQ_DEF_EXPIRATION_DATE as CHG_REQ_6_1_, changerequ2_.PROCESS_TYPE as PROCESS_7_1_, changerequ2_.CHG_REQUEST_DEF_DESCRIPTION as CHG_REQU8_1_, changerequ2_.WEB_PAGE as WEB_PAGE1_, changerequ2_.NUMBER_OF_DAYS as NUMBER_10_1_, changerequ2_.PROGRAM_ID as PROGRAM_ID1_, changerequ2_.CHG_REQ_DEF_CREATE_DATE as CHG_REQ12_1_, changerequ2_.CHG_REQ_DEF_CREATE_USERID as CHG_REQ13_1_, changerequ2_.CHG_REQ_DEF_LAST_CHG_USERID as CHG_REQ14_1_ from work.change_request changerequ0_ left outer join work.endorsement_transaction endorsemen1_ on changerequ0_.transaction_id=endorsemen1_.TRANSACTION_ID left outer join work.CHANGE_REQUEST_DEF changerequ2_ on changerequ0_.change_request_code=changerequ2_.CHANGE_REQUEST_CODE where changerequ0_.TRANSACTION_ID=? and changerequ0_.TRANSACTION_SEQUENCE=?[/b]
2004-03-25 15:06:31,777 DEBUG impl.BatcherImpl  - preparing statement
2004-03-25 15:06:31,918 DEBUG type.StringType  - binding '2koUgYNJzeyLvw9LnWwO0U' to parameter: 1
2004-03-25 15:06:31,918 DEBUG type.IntegerType  - binding '0' to parameter: 2
2004-03-25 15:06:31,958 DEBUG loader.Loader  - processing result set
2004-03-25 15:06:31,958 DEBUG loader.Loader  - done processing result set (0 rows)
2004-03-25 15:06:31,958 DEBUG impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-03-25 15:06:31,958 DEBUG impl.BatcherImpl  - closing statement
2004-03-25 15:06:31,958 DEBUG loader.Loader  - total objects hydrated: 0
2004-03-25 15:06:31,958 DEBUG impl.SessionImpl  - initializing non-lazy collections
2004-03-25 15:06:31,958 WARN  persistence.HibernateUtil  - Exception while loading object with uid 'com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0]'
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: com.pratap.hibernate.vos.ChangeRequestKey@55eb1973[transactionId=2koUgYNJzeyLvw9LnWwO0U,transactionSequence=0], of class: com.pratap.hibernate.vos.ChangeRequestVO
   at net.sf.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:24)
   at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1885)
   at com.pratap.hibernate.persistence.HibernateUtil.load(HibernateUtil.java:320)
   at com.pratap.hibernate.businessobjects.ChangeRequestBusinessObjectImpl.read(ChangeRequestBusinessObjectImpl.java:93)
   at com.pratap.hibernate.tests.businessobject.ChangeRequestBusinessObjectImplTest.testRead(ChangeRequestBusinessObjectImplTest.java:142)
   at java.lang.reflect.Method.invoke(Native Method)
   at junit.framework.TestCase.runTest(TestCase.java:166)
   at junit.framework.TestCase.runBare(TestCase.java:140)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:131)
   at junit.framework.TestSuite.runTest(TestSuite.java:173)
   at junit.framework.TestSuite.run(TestSuite.java:168)
   at junit.textui.TestRunner.doRun(TestRunner.java:74)
   at junit.textui.TestRunner.run(TestRunner.java:200)
   at com.pratap.hibernate.tests.businessobject.ChangeRequestBusinessObjectImplTest.main(ChangeRequestBusinessObjectImplTest.java:229)
2004-03-25 15:06:31,978 DEBUG impl.SessionImpl  - closing session
2004-03-25 15:06:31,978 DEBUG impl.SessionImpl  - disconnecting session
2004-03-25 15:06:31,978 DEBUG connection.DriverManagerConnectionProvider  - returning connection to pool, pool size: 1
2004-03-25 15:06:31,978 DEBUG impl.SessionImpl  - transaction completion
2004-03-25 15:06:32,038 DEBUG tests.AbstractEndorsementsTest  - [statement 'delete from change_request where transaction_id = '2koUgYNJzeyLvw9LnWwO0U'' executed.]
2004-03-25 15:06:32,178 DEBUG tests.AbstractEndorsementsTest  - [statement 'delete from endorsement_transaction where transaction_id = '2koUgYNJzeyLvw9LnWwO0U'' executed.]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 25, 2004 5:59 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
have written equals & hashcode methods well?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 29, 2004 12:53 pm 
Newbie

Joined: Wed Feb 04, 2004 1:25 am
Posts: 8
sorry for taking so long... but yes I have coded both those EqualsBuilder and HashCodeBuilder.

Code:
    ChangeRequestVO

    public boolean equals(Object other) {
        if ( !(other instanceof ChangeRequestVO) ) return false;
        ChangeRequestVO castOther = (ChangeRequestVO) other;
        // type of compId is ChangeRequestKey
        return new EqualsBuilder()
            .append(this.getCompId(), castOther.getCompId())
            .isEquals();
    }

    public int hashCode() {
        return new HashCodeBuilder()
            .append(getCompId())
            .toHashCode();
    }

Code:
    ChangeRequestKey
    public boolean equals(Object other) {
        if ( !(other instanceof ChangeRequestKey) ) return false;
        ChangeRequestKey castOther = (ChangeRequestKey) other;
        return new EqualsBuilder()
            .append(this.getTransactionId(), castOther.getTransactionId())
            .append(this.getTransactionSequence(), castOther.getTransactionSequence())
            .isEquals();
    }

    public int hashCode() {
        return new HashCodeBuilder()
            .append(getTransactionId())
            .append(getTransactionSequence())
            .toHashCode();
    }


Code:
     ChangeRequestDefVO
    public boolean equals(Object other) {
        if ( !(other instanceof ChangeRequestDefVO) ) return false;
        ChangeRequestDefVO castOther = (ChangeRequestDefVO) other;
        return new EqualsBuilder()
            .append(this.getCode(), castOther.getCode())
            .isEquals();
    }

    public int hashCode() {
        return new HashCodeBuilder()
            .append(getCode())
            .toHashCode();
    }


any other reasons why this could be failing? Again if I remove the many-to-one mapping (name="definition") in the ChangeRequestVO config, all works fine. So it is failing when loading the ChangeDefVO ??

pratap.


Top
 Profile  
 
 Post subject: Similar issue
PostPosted: Wed Apr 07, 2004 1:14 pm 
Newbie

Joined: Wed Apr 07, 2004 11:45 am
Posts: 1
I am having a similar issue with many-to-one. In my case, the outer join does not always return a record because there isn't always a description for a given code. Hibernate runs the select statement with the join and gets the results, then runs another select to try to get the rows from the lookup table that didn't come back with the first select. 'Course, the data is not there, so I get the 'ObjectNotFoundException'.

I'd prefer to have Hibernate set the contained object to null if the outer join returned no data for that id, but I'd take anything other than the ObjectNotFoundException.

Here's the code:

Code:
/**
* @hibernate.many-to-one
*  column="CODE_ID"
*  outer-join="true"
*
* @return CodeDescriptionValue
*/
public CodeDescriptionValue getCode() { return code;   }
public void setCode(CodeDescriptionValue value) { code = value; }


And the session.find call:

Code:
List list = session.find("FROM CodeValue objTable " +
                               "LEFT JOIN FETCH objTable.code " +
                               "WHERE ID = ? " +
                  "ORDER BY objTable.id ASC", values, types);


I realize this is probably a newbie question, but I haven't been able to find the answer in the docs or forums. I can't imagine that hibernate doesn't support this functionality, so I must be doing something wrong.


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.