-->
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.  [ 6 posts ] 
Author Message
 Post subject: Bad sql generated by OneToManyPersister with composite key
PostPosted: Fri Sep 03, 2004 2:56 pm 
Newbie

Joined: Fri Aug 20, 2004 1:13 pm
Posts: 10
Hibernate version:2.1.6 from cvs
Name and version of the database you are using:sqlserver2k


I am seeing a problem wherein the sql generated for a eager load collection is wrong. Specifically, hibernate appears to be reversing the sense of the keys when it creates the prepared statement. Look at the statements below (grabbed by sql profiler):


declare @P1 int
set @P1=3
exec sp_prepare @P1 output, N'@p1 nvarchar(4000),@p2 nvarchar(4000)', N'select wellboreop0_.SYSTEM_WELL_ID_NUMBER as SYSTEM_W3___,
... columns elimitated for clarity...
wellboreop0_.RECORD_MODIFICATION_BY as RECORD_26_0_ from WELLBORE_OPERATOR wellboreop0_ where wellboreop0_.SYSTEM_WELL_ID_NUMBER=@p1 and wellboreop0_.WELL_COMPLETION_NUMBER=@p2'
select @P1

exec sp_execute 3, N'0', N'fd82b140-56f0-4443-84c3-000047a45805'


Note that when it executes the prepared statement, it has reversed the SYSTEM_WELL_ID_NUMBER and the WELL_COMPLETION_NUMBER.

The problem seems to be that the OneToManyPersister is holding an array, keyColumnNames[] that hold the column names in an order different than the order held by OneToManyLoader.queryParameters

Im still trying to debug it further but wanted to see if maybe I was doing something dumb. If I cant find the problem, Ill simplify it to a test case that demonstrates the problem more clearly.



Mapping documents:
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class name="com.drillinginfo.pennwell.hibernate.WellHeader" table="WELL_HEADER">
<id name="systemWellIdNumber" column="SYSTEM_WELL_ID_NUMBER" type="java.lang.String">
<generator class="assigned"/>
</id>
<property name="uwiDataSource" type="java.lang.String"
column="UWI_DATA_SOURCE" length="20"/>
<property name="apiStateCode" type="java.lang.String"
column="API_STATE_CODE" length="2"/>
<property name="apiCountyCode" type="java.lang.String"
column="API_COUNTY_CODE" length="3"/>
<property name="apiUniqueNumber" type="java.lang.String"
column="API_UNIQUE_NUMBER" length="5"/>
<property name="offshoreFlag" type="java.lang.String"
column="OFFSHORE_FLAG" length="1"/>
<property name="basinCode" type="java.lang.String" column="BASIN_CODE" length="8"/>
<property name="fieldCode" type="java.lang.String" column="FIELD_CODE" length="16"/>
<property name="fieldName" type="java.lang.String" column="FIELD_NAME" length="64"/>
<property name="comments" type="java.lang.String" column="COMMENTS" length="256"/>
<property name="recordLoadDate" type="java.sql.Timestamp"
column="RECORD_LOAD_DATE" length="23"/>
<property name="recordModificationDate" type="java.sql.Timestamp"
column="RECORD_MODIFICATION_DATE" length="23"/>
<property name="recordModificationBy" type="java.lang.String"
column="RECORD_MODIFICATION_BY" length="32"/>
<!-- associations
bi-directional one-to-many association to Wellbore -->
<set name="wellbores" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.Wellbore"/>
</set>
<set name="RWwellIds" outer-join="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.RWellid"/>
</set>
</class>
</hibernate-mapping>



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class name="com.drillinginfo.pennwell.hibernate.Wellbore" table="WELLBORE">
<composite-id class="com.drillinginfo.pennwell.hibernate.WellborePK"
name="comp_id" unsaved-value="none">
<key-property name="wellCompletionNumber" type="java.lang.String"
column="WELL_COMPLETION_NUMBER" length="8"/>
<!-- bi-directional many-to-one association to WellHeader -->
<key-many-to-one name="wellHeader" class="com.drillinginfo.pennwell.hibernate.WellHeader">
<column name="SYSTEM_WELL_ID_NUMBER"/>
</key-many-to-one>
</composite-id>
<property name="uwiDataSource" type="java.lang.String"
column="UWI_DATA_SOURCE" length="20"/>
<property name="boreholeTypeCode" type="java.lang.String"
column="BOREHOLE_TYPE_CODE" length="8"/>
<property name="completionCode" type="java.lang.String"
column="COMPLETION_CODE" length="8"/>
<property name="completionResultCode" type="java.lang.String"
column="COMPLETION_RESULT_CODE" length="8"/>
<property name="wellboreProposedStatusCode" type="java.lang.String"
column="WELLBORE_PROPOSED_STATUS_CODE" length="16"/>
<property name="wellboreFinalStatusCode" type="java.lang.String"
column="WELLBORE_FINAL_STATUS_CODE" length="16"/>
<property name="wellboreFinalStatusDate" type="java.sql.Timestamp"
column="WELLBORE_FINAL_STATUS_DATE" length="23"/>
<property name="wellboreTypeCode" type="java.lang.String"
column="WELLBORE_TYPE_CODE" length="8"/>
<property name="wellboreSidetrackNumber" type="java.lang.String"
column="WELLBORE_SIDETRACK_NUMBER" length="3"/>
<property name="cnum" type="java.lang.String" column="CNUM" length="4"/>
<property name="wellboreCurrentStatusCode" type="java.lang.String"
column="WELLBORE_CURRENT_STATUS_CODE" length="16"/>
<property name="wellboreCurrentStatusDate" type="java.sql.Timestamp"
column="WELLBORE_CURRENT_STATUS_DATE" length="23"/>
<property name="wellboreInitialAapgClassificationCode"
type="java.lang.String"
column="WELLBORE_INITIAL_AAPG_CLASSIFICATION_CODE" length="1"/>
<property name="wellboreFinalAapgClassificationCode"
type="java.lang.String"
column="WELLBORE_FINAL_AAPG_CLASSIFICATION_CODE" length="1"/>
<property name="permitNumber" type="java.lang.String"
column="PERMIT_NUMBER" length="16"/>
<property name="permitDate" type="java.sql.Timestamp"
column="PERMIT_DATE" length="23"/>
<property name="amendedPermitDate" type="java.sql.Timestamp"
column="AMENDED_PERMIT_DATE" length="23"/>
<property name="permitFilerName" type="java.lang.String"
column="PERMIT_FILER_NAME" length="64"/>
<property name="permitFilerTitle" type="java.lang.String"
column="PERMIT_FILER_TITLE" length="64"/>
<property name="permitFilerPhone" type="java.lang.String"
column="PERMIT_FILER_PHONE" length="32"/>
<property name="fieldCode" type="java.lang.String" column="FIELD_CODE" length="16"/>
<property name="fieldName" type="java.lang.String" column="FIELD_NAME" length="64"/>
<property name="producingReservoirName" type="java.lang.String"
column="PRODUCING_RESERVOIR_NAME" length="32"/>
<property name="producingLeaseNumber" type="java.lang.String"
column="PRODUCING_LEASE_NUMBER" length="16"/>
<property name="producingWellNumber" type="java.lang.String"
column="PRODUCING_WELL_NUMBER" length="16"/>
<property name="originalOperatorName" type="java.lang.String"
column="ORIGINAL_OPERATOR_NAME" length="64"/>
<property name="originalOperatorCode" type="java.lang.String"
column="ORIGINAL_OPERATOR_CODE" length="16"/>
<property name="leaseName" type="java.lang.String" column="LEASE_NAME" length="64"/>
<property name="wellNumber" type="java.lang.String"
column="WELL_NUMBER" length="32"/>
<property name="depthUomCode" type="java.lang.String"
column="DEPTH_UOM_CODE" length="8"/>
<property name="proposedMtd" type="java.math.BigDecimal"
column="PROPOSED_MTD" length="8"/>
<property name="proposedTvd" type="java.math.BigDecimal"
column="PROPOSED_TVD" length="8"/>
<property name="finalMtd" type="java.math.BigDecimal"
column="FINAL_MTD" length="8"/>
<property name="finalTvd" type="java.math.BigDecimal"
column="FINAL_TVD" length="8"/>
<property name="totalDepthDate" type="java.sql.Timestamp"
column="TOTAL_DEPTH_DATE" length="23"/>
<property name="plugbackMtd" type="java.math.BigDecimal"
column="PLUGBACK_MTD" length="8"/>
<property name="plugbackTvd" type="java.math.BigDecimal"
column="PLUGBACK_TVD" length="8"/>
<property name="plugbackDepthDate" type="java.sql.Timestamp"
column="PLUGBACK_DEPTH_DATE" length="23"/>
<property name="objectiveFmName" type="java.lang.String"
column="OBJECTIVE_FM_NAME" length="32"/>
<property name="objectiveFmNameCode" type="java.lang.String"
column="OBJECTIVE_FM_NAME_CODE" length="16"/>
<property name="objectiveFmAgeCode" type="java.lang.String"
column="OBJECTIVE_FM_AGE_CODE" length="8"/>
<property name="fmAtTdName" type="java.lang.String"
column="FM_AT_TD_NAME" length="32"/>
<property name="fmAtTdNameCode" type="java.lang.String"
column="FM_AT_TD_NAME_CODE" length="16"/>
<property name="fmAtTdAgeCode" type="java.lang.String"
column="FM_AT_TD_AGE_CODE" length="8"/>
<property name="oldestFmName" type="java.lang.String"
column="OLDEST_FM_NAME" length="32"/>
<property name="oldestFmNameCode" type="java.lang.String"
column="OLDEST_FM_NAME_CODE" length="16"/>
<property name="oldestFmAgeCode" type="java.lang.String"
column="OLDEST_FM_AGE_CODE" length="8"/>
<property name="drillingContractorName" type="java.lang.String"
column="DRILLING_CONTRACTOR_NAME" length="64"/>
<property name="drillingContractorStatusCode" type="java.lang.String"
column="DRILLING_CONTRACTOR_STATUS_CODE" length="8"/>
<property name="rigNumber" type="java.lang.String" column="RIG_NUMBER" length="64"/>
<property name="locationReportDate" type="java.sql.Timestamp"
column="LOCATION_REPORT_DATE" length="23"/>
<property name="spudDate" type="java.sql.Timestamp" column="SPUD_DATE" length="23"/>
<property name="spudDateTypeCode" type="java.lang.String"
column="SPUD_DATE_TYPE_CODE" length="8"/>
<property name="completionReportDate" type="java.sql.Timestamp"
column="COMPLETION_REPORT_DATE" length="23"/>
<property name="completionDate" type="java.sql.Timestamp"
column="COMPLETION_DATE" length="23"/>
<property name="rigOnsiteDate" type="java.sql.Timestamp"
column="RIG_ONSITE_DATE" length="23"/>
<property name="rigReleaseDate" type="java.sql.Timestamp"
column="RIG_RELEASE_DATE" length="23"/>
<property name="abandonLocationDate" type="java.sql.Timestamp"
column="ABANDON_LOCATION_DATE" length="23"/>
<property name="historicalDataEntryDate" type="java.sql.Timestamp"
column="HISTORICAL_DATA_ENTRY_DATE" length="23"/>
<property name="wellboreExhaustionDate" type="java.sql.Timestamp"
column="WELLBORE_EXHAUSTION_DATE" length="23"/>
<property name="wellboreFileStatusCode" type="java.lang.String"
column="WELLBORE_FILE_STATUS_CODE" length="8"/>
<property name="comments" type="java.lang.String" column="COMMENTS" length="256"/>
<property name="recordLoadDate" type="java.sql.Timestamp"
column="RECORD_LOAD_DATE" length="23"/>
<property name="recordModificationDate" type="java.sql.Timestamp"
column="RECORD_MODIFICATION_DATE" length="23"/>
<property name="recordModificationBy" type="java.lang.String"
column="RECORD_MODIFICATION_BY" length="32"/>
<!-- associations
bi-directional one-to-many association to WellboreCor -->
<set name="wellboreCors" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreCor"/>
</set>
<!-- bi-directional one-to-many association to WellCongressLocation -->
<set name="wellCongressLocations" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellCongressLocation"/>
</set>
<!-- bi-directional one-to-many association to WellboreTest -->
<set name="wellboreTests" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreTest"/>
</set>
<!-- bi-directional one-to-many association to WellboreNotesNarrative -->
<set name="wellboreNotesNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreNotesNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellboreCasingNarrative -->
<set name="wellboreCasingNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreCasingNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellboreLithNarrative -->
<set name="wellboreLithNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreLithNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellborePerforation -->
<set name="wellborePerforations" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellborePerforation"/>
</set>
<!-- bi-directional one-to-many association to WellSphericalLocation -->
<set name="wellSphericalLocations" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellSphericalLocation"/>
</set>
<!-- bi-directional one-to-many association to WellboreLogsNarrative -->
<set name="wellboreLogsNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreLogsNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellboreShow -->
<set name="wellboreShows" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreShow"/>
</set>
<!-- bi-directional one-to-many association to WellOffshoreLocation -->
<set name="wellOffshoreLocations" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellOffshoreLocation"/>
</set>
<!-- bi-directional one-to-many association to WellboreLocNarrative -->
<set name="wellboreLocNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreLocNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellboreJourNarrative -->
<set name="wellboreJourNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreJourNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellboreNearestCity -->
<set name="wellboreNearestCities" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreNearestCity"/>
</set>
<!-- bi-directional one-to-many association to WellboreTcommNarrative -->
<set name="wellboreTcommNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreTcommNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellboreFormationPick -->
<set name="wellboreFormationPicks" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreFormationPick"/>
</set>
<!-- bi-directional one-to-many association to WellboreMungerNarrative -->
<set name="wellboreMungerNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreMungerNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellIdentifier -->
<set name="wellIdentifiers" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellIdentifier"/>
</set>
<!-- bi-directional one-to-many association to WellboreElevation -->
<set name="wellboreElevations" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreElevation"/>
</set>
<!-- bi-directional one-to-many association to WellborePreSpudNarrative -->
<set name="wellborePreSpudNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellborePreSpudNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellboreOperator -->
<set name="wellboreOperators" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreOperator"/>
</set>
<!-- bi-directional one-to-many association to WellboreProdZone -->
<set name="wellboreProdZones" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreProdZone"/>
</set>
<!-- bi-directional one-to-many association to WellboreDst -->
<set name="wellboreDsts" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreDst"/>
</set>
<!-- bi-directional one-to-many association to WellboreMudNarrative -->
<set name="wellboreMudNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreMudNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellboreTubingNarrative -->
<set name="wellboreTubingNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreTubingNarrative"/>
</set>
<!-- bi-directional one-to-many association to WellTexasLocation -->
<set name="wellTexasLocations" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellTexasLocation"/>
</set>
<!-- bi-directional one-to-many association to WellboreBhLocationNarrative -->
<set name="wellboreBhLocationNarratives" lazy="true" inverse="true">
<key>
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key>
<one-to-many class="com.drillinginfo.pennwell.hibernate.WellboreBhLocationNarrative"/>
</set>
</class>
</hibernate-mapping>


<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class name="com.drillinginfo.pennwell.hibernate.WellboreOperator" table="WELLBORE_OPERATOR">
<composite-id
class="com.drillinginfo.pennwell.hibernate.WellboreOperatorPK"
name="comp_id" unsaved-value="none">
<key-property name="sequenceNumber" type="java.lang.Integer"
column="SEQUENCE_NUMBER" length="10"/>
<!-- bi-directional many-to-one association to Wellbore -->
<key-many-to-one name="wellbore" class="com.drillinginfo.pennwell.hibernate.Wellbore">
<column name="WELL_COMPLETION_NUMBER"/>
<column name="SYSTEM_WELL_ID_NUMBER"/>
</key-many-to-one>
</composite-id>
<property name="uwiDataSource" type="java.lang.String"
column="UWI_DATA_SOURCE" length="20"/>
<property name="operatorCode" type="java.lang.String"
column="OPERATOR_CODE" length="16"/>
<property name="operatorTypeCode" type="java.lang.String"
column="OPERATOR_TYPE_CODE" length="8"/>
<property name="operatorName" type="java.lang.String"
column="OPERATOR_NAME" length="64"/>
<property name="city" type="java.lang.String" column="CITY" length="64"/>
<property name="statePostalCode" type="java.lang.String"
column="STATE_POSTAL_CODE" length="2"/>
<property name="countryCode" type="java.lang.String"
column="COUNTRY_CODE" length="8"/>
<property name="address1" type="java.lang.String" column="ADDRESS_1" length="64"/>
<property name="address2" type="java.lang.String" column="ADDRESS_2" length="64"/>
<property name="zipCode" type="java.lang.String" column="ZIP_CODE" length="10"/>
<property name="officeType" type="java.lang.String"
column="OFFICE_TYPE" length="32"/>
<property name="primaryContact" type="java.lang.String"
column="PRIMARY_CONTACT" length="128"/>
<property name="primaryContactTitle" type="java.lang.String"
column="PRIMARY_CONTACT_TITLE" length="128"/>
<property name="primaryContactEmailAddress" type="java.lang.String"
column="PRIMARY_CONTACT_EMAIL_ADDRESS" length="256"/>
<property name="phoneNumber" type="java.lang.String"
column="PHONE_NUMBER" length="32"/>
<property name="faxNumber" type="java.lang.String" column="FAX_NUMBER" length="32"/>
<property name="corporationWebAddress" type="java.lang.String"
column="CORPORATION_WEB_ADDRESS" length="256"/>
<property name="operatorEffectiveDateBegin" type="java.sql.Timestamp"
column="OPERATOR_EFFECTIVE_DATE_BEGIN" length="23"/>
<property name="operatorEffectiveDateEnd" type="java.sql.Timestamp"
column="OPERATOR_EFFECTIVE_DATE_END" length="23"/>
<property name="comments" type="java.lang.String" column="COMMENTS" length="256"/>
<property name="recordLoadDate" type="java.sql.Timestamp"
column="RECORD_LOAD_DATE" length="23"/>
<property name="recordModificationDate" type="java.sql.Timestamp"
column="RECORD_MODIFICATION_DATE" length="23"/>
<property name="recordModificationBy" type="java.lang.String"
column="RECORD_MODIFICATION_BY" length="32"/>
</class>
</hibernate-mapping>






Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

net.sf.hibernate.JDBCException: could not initialize collection: [com.drillinginfo.pennwell.hibernate.Wellbore.wellboreOperators#com.drillinginfo.pennwell.hibernate.WellborePK@e2d858[wellCompletionNumber=0,wellHeader=com.drillinginfo.pennwell.hibernate.WellHeader@2870b7[systemWellIdNumber=fd82b140-56f0-4443-84c3-000047a45805]]]
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:287)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3272)
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:336)
at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3127)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1034)
at net.sf.hibernate.loader.Loader.list(Loader.java:1025)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1545)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.drillinginfo.struts.actions.pennwell.WellboreView.customPerform(WellboreView.java:74)
at com.drillinginfo.struts.actions.DIAction.execute(DIAction.java:61)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534)
Caused by: com.inet.tds.SQLException: Msg 8169, Level 16, State 2, Line
1, Sqlstate 01000
[C0DB1\DEV1]Syntax error converting from a character string to uniqueidentifier.
at com.inet.tds.a.a(Unknown Source)
at com.inet.tds.a.a(Unknown Source)
at com.inet.tds.c.new(Unknown Source)
at com.inet.tds.c.executeQuery(Unknown Source)
at com.drillinginfo.util.StatementWrapper.executeQuery(StatementWrapper.java:157)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:876)
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.loadCollection(Loader.java:991)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:966)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:93)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)

Debug level Hibernate log excerpt:

_________________
-alan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 3:14 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
The order of the keys of the one to many must match your comp PK definition.

I believe Middlegen has the tendency to reverse one set of these causing the generated code not to match. I suspect this is your problem.

Try changing
<key-many-to-one name="wellbore" class="com.drillinginfo.pennwell.hibernate.Wellbore">
<column name="WELL_COMPLETION_NUMBER"/>
<column name="SYSTEM_WELL_ID_NUMBER"/>
</key-many-to-one>

to
<key-many-to-one name="wellbore" class="com.drillinginfo.pennwell.hibernate.Wellbore">
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key-many-to-one>

and that should solve your issue.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 4:05 pm 
Newbie

Joined: Fri Aug 20, 2004 1:13 pm
Posts: 10
reversing the column names so that I have this:

<key-many-to-one name="wellbore" class="com.drillinginfo.pennwell.hibernate.Wellbore">
<column name="SYSTEM_WELL_ID_NUMBER"/>
<column name="WELL_COMPLETION_NUMBER"/>
</key-many-to-one>

didnt help (I had tried that). I'll keep playing with it though.

_________________
-alan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 4:58 pm 
Newbie

Joined: Fri Aug 20, 2004 1:13 pm
Posts: 10
i think something is really broken (or at least fragil) with the OneToManyLoader.bindPositionalParameters(..).

It seems parameters are bound into the ps in a order that is determined by the order in which the optimizer (or whatever relection mechanism) lists the getters for the ComponentType (in this case a WellborePK). That order is basically random as far as I can tell. There doesnt appear to be any reconcilication between that order and the orer the OneToManyPersister orders the keyColumnNames when it write the sql.

Either that or maybe I am just confused :)

_________________
-alan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 7:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You are wrong. The ComponentType will have its properties in the same order they were listed in the <composite-id> declaration.

Simplify and then fix your code, stop blaming Hibernate.


Top
 Profile  
 
 Post subject: im an idiot
PostPosted: Wed Sep 08, 2004 10:20 am 
Newbie

Joined: Fri Aug 20, 2004 1:13 pm
Posts: 10
Your right, Im wrong. I had some bad config. Sorry for the false alarm

_________________
-alan


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