christian wrote:
There is not much left to explain, I guess. If you say "NOT NULL", you say "requires a reference". If you don't want that reference, don't say NOT NULL. There is no magic that will help here.
Thanks for confirming my understanding here...I was looking for some vodoo here! ;o) And yes, we're looking at the XML Serialization as well. Just looking at approaches from all angles.
I do have one last question and then I'll put this to rest. I have cascade save-update set up on the Set of children in the parent with a unidirectional relationship set-up and the FK as nullable. When I save a brand new parent that has a brand new child in its Set, I see the log below when I have debug on and the records persist successfully.
Hibernate makes the INSERT INTO to my parent, then INSERT INTO into my child, and then an UPDATE on the child to update the FK in the child table? Here's where I was looking for the vodoo magic where Hibernate could somehow dynamically combine the latter INSERT INTO and UPDATE into one statement, thus fullfilling the NOT NULL constraint on the FK.
I understand what you're saying about NOT NULL equaling defined reference, and I can live with that, but some vodoo to add the key behind the scenes would be cool too! That's the essence of my JIRA request.
Again thanks,
Lou
Code:
11:37:54,733 DEBUG SQL:237 - insert into CLM_CLAIM (TCN, LAW_ENFORCEMENT_FLAG, EPD_ORG_USER_ID, UPDATED_BY, CO_CD, UPDATED_DT, CLAIM_PROPERTY_FLAG, ARCHIVE_FLAG, CLAIM_NUMBER, CREATED_DT, CREATED_BY, FRAUD_INV_FLAG, POLICY_NUMBER, CLAIM_SENSITIVITY_FLAG, CLAIM_SENSITIVITY_CATEGORY, EPD_ORG_ID, WITNESS_FLAG, CLAIM_MEMO, SET_FOR_AUDIT, ARCHIVE_DATE, INJURED_FLAG, LOSS_EVENT_ID, CLAIM_STATUS_CD, CLAIM_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
11:37:54,733 DEBUG BatcherImpl:241 - preparing statement
11:37:54,733 DEBUG EntityPersister:388 - Dehydrating entity: [com.mitchell.services.technical.claim.dao.vo.ClmClaim#240]
11:37:54,733 DEBUG LongType:46 - binding '0' to parameter: 1
11:37:54,733 DEBUG StringType:46 - binding 'F' to parameter: 2
11:37:54,733 DEBUG IntegerType:46 - binding '1234' to parameter: 3
11:37:54,748 DEBUG StringType:46 - binding 'lsacco' to parameter: 4
11:37:54,748 DEBUG StringType:46 - binding 'JH' to parameter: 5
11:37:54,748 DEBUG TimestampType:46 - binding '02 August 2004 11:37:48' to parameter: 6
11:37:54,748 DEBUG StringType:46 - binding 'Y' to parameter: 7
11:37:54,748 DEBUG StringType:46 - binding 'Y' to parameter: 8
11:37:54,748 DEBUG StringType:46 - binding '84642004' to parameter: 9
11:37:54,748 DEBUG TimestampType:46 - binding '02 August 2004 11:37:48' to parameter: 10
11:37:54,764 DEBUG StringType:46 - binding 'lsacco' to parameter: 11
11:37:54,764 DEBUG StringType:46 - binding 'F' to parameter: 12
11:37:54,764 DEBUG StringType:46 - binding '123897034ASDF' to parameter: 13
11:37:54,764 DEBUG StringType:46 - binding 'F' to parameter: 14
11:37:54,764 DEBUG StringType:41 - binding null to parameter: 15
11:37:54,764 DEBUG IntegerType:46 - binding '235' to parameter: 16
11:37:54,764 DEBUG StringType:46 - binding 'T' to parameter: 17
11:37:54,764 DEBUG StringType:46 - binding 'Hello Der' to parameter: 18
11:37:54,764 DEBUG StringType:46 - binding 'F' to parameter: 19
11:37:54,764 DEBUG TimestampType:46 - binding '02 August 2004 11:37:48' to parameter: 20
11:37:54,764 DEBUG StringType:46 - binding 'F' to parameter: 21
11:37:54,764 DEBUG LongType:41 - binding null to parameter: 22
11:37:54,764 DEBUG Cascades:341 - id unsaved-value strategy NULL
11:37:54,764 DEBUG StringType:46 - binding 'open' to parameter: 23
11:37:54,764 DEBUG LongType:46 - binding '240' to parameter: 24
11:37:54,764 DEBUG BatcherImpl:28 - Adding to batch
11:37:54,780 DEBUG EntityPersister:453 - Inserting entity: [com.mitchell.services.technical.claim.dao.vo.ClmClaimExposure#166]
11:37:54,780 DEBUG EntityPersister:454 - Version: 0
11:37:54,780 DEBUG BatcherImpl:50 - Executing batch size: 1
11:37:54,811 DEBUG BatcherImpl:58 - success of batch update unknown: 0
11:37:54,811 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
11:37:54,811 DEBUG BatcherImpl:261 - closing statement
11:37:54,826 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
11:37:54,826 DEBUG SQL:237 - insert into CLM_CLAIM_EXPOSURE (TCN, EPD_ORG_USER_ID, CO_CD, UPDATED_BY, UPDATED_DT, EXPOSURE_NUMBER, CLAIM_NUMBER, CREATED_BY, CREATED_DT, EPD_ORG_ID, CWQ_CLM_WORK_QUEUE_ID, DESCRIPTION_OF_WHAT_HAPPENED, TOTAL_CLAIM_EXPOSURE_AMOUNT, SET_1_SETTLEMENT_ID, DEDUCTIBLE_AMOUNT, DATE_OF_LOSS, CLM_VEH_CLAIM_VEHICLE_ID, LOSS_TYPE, POLICY_COVERAGE_ID, COVERAGE_TYPE_CODE, CLAIM_EXPOSURE_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
11:37:54,826 DEBUG BatcherImpl:241 - preparing statement
11:37:54,826 DEBUG EntityPersister:388 - Dehydrating entity: [com.mitchell.services.technical.claim.dao.vo.ClmClaimExposure#166]
11:37:54,826 DEBUG LongType:46 - binding '0' to parameter: 1
11:37:54,826 DEBUG IntegerType:46 - binding '1234' to parameter: 2
11:37:54,826 DEBUG StringType:46 - binding 'JH' to parameter: 3
11:37:54,826 DEBUG StringType:46 - binding 'lsacco' to parameter: 4
11:37:54,826 DEBUG TimestampType:46 - binding '02 August 2004 11:37:48' to parameter: 5
11:37:54,826 DEBUG StringType:46 - binding '1684641988' to parameter: 6
11:37:54,826 DEBUG StringType:46 - binding '84642004' to parameter: 7
11:37:54,826 DEBUG StringType:46 - binding 'lsacco' to parameter: 8
11:37:54,826 DEBUG TimestampType:46 - binding '02 August 2004 11:37:48' to parameter: 9
11:37:54,826 DEBUG IntegerType:46 - binding '235' to parameter: 10
11:37:54,826 DEBUG IntegerType:46 - binding '1' to parameter: 11
11:37:54,826 DEBUG StringType:46 - binding 'This guy just crashed into me' to parameter: 12
11:37:54,826 DEBUG BigDecimalType:46 - binding '5000' to parameter: 13
11:37:54,826 DEBUG IntegerType:46 - binding '123' to parameter: 14
11:37:54,826 DEBUG BigDecimalType:46 - binding '500' to parameter: 15
11:37:54,842 DEBUG TimestampType:46 - binding '02 August 2004 11:37:48' to parameter: 16
11:37:54,842 DEBUG LongType:41 - binding null to parameter: 17
11:37:54,842 DEBUG StringType:41 - binding null to parameter: 18
11:37:54,842 DEBUG LongType:41 - binding null to parameter: 19
11:37:54,842 DEBUG StringType:41 - binding null to parameter: 20
11:37:54,842 DEBUG LongType:46 - binding '166' to parameter: 21
11:37:54,842 DEBUG BatcherImpl:28 - Adding to batch
11:37:54,951 DEBUG BasicCollectionPersister:508 - Inserting collection: [com.mitchell.services.technical.claim.dao.vo.ClmClaim.exposureSet#240]
11:37:54,951 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
11:37:54,951 DEBUG SQL:237 - update CLM_CLAIM_EXPOSURE set CLA_CLAIM_ID=? where CLAIM_EXPOSURE_ID=?
11:37:54,951 DEBUG BatcherImpl:241 - preparing statement
11:37:54,951 DEBUG LongType:46 - binding '240' to parameter: 1
11:37:54,951 DEBUG LongType:46 - binding '166' to parameter: 2