Hibernate Version : v2.1
I am having some problem while executing the insert query through hibernate.
Let me give you an overview about my work around.
Please refer to the model attached for data model w.r.t physical data model.
Here LoanPartyRole is the representation of Mapping table called "LOAN_PARTY_MAPPING"
which have references from PARTY, HOME_LOAN and PARTY_TYPE.
Then PARTY has references with PERSON and ORGANIZATION.
For all these we have inheritance mapping. Please refer to mappings attached.
Now while inserting I am getting this error:
Hibernate: select PROPERTY.nextval from dual
Hibernate: insert into PROPERTY (VERSION_NUMBER, PROPERTY_TYPE_CODE, LOCATION, OCCUPANCY_INDICATOR, STATED_VALUE, PURCHASE_PRICE, ESTIMATED_APPRAISAL_VALUE, ACQUISITION_DATE, MSA_IDENTIFIER, CRA_DELINEATED_COMMUNITY_TYPE, LEGAL_DESCRIPTION, CREATED_BY, CREATE_DATE, PROPERTY_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into PROPERTY_ADDRESS (VERSION_NUMBER, CITY_NAME, STATE_PROVINCE_CODE, ZIP_CODE, COUNTRY_CODE, ADDRESS_LINE1, ADDRESS_LINE2, ADDRESS_LINE3, CREATED_BY, PROPERTY_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into HOME_LOAN (LOAN_NUMBER, PREFERRED_LANGUAGE, CLOSING_DATE, UNFUND_DATE, FUNDING_DATE, MATURITY_DATE, LOAN_TYPE, INTEREST_AMOUNT, PREPAY_PENALTY_TERM, ORIGINATION_TYPE_CODE, NEXT_PAYMENT_DUE_DATE, PRINCIPAL_REDUCTION_AMOUNT, THIRD_LIEN_INDICATOR, CUNCURRENT_LOAN_INDICATOR, BUSINESS_LINE, SEASONAL_BALOON_INDICATOR, REFI_PURPOSE, INTERNAL_REFI_INDICATOR, DOCUMENT_PRINT_DATE, ESTIMATED_FUNDING_DATE, LIEN_NUMBER, CREATED_BY, LAST_UPDATED_BY, TERM_FIRST_PAYMENT, ASSUMPTION_IND, BALLOON_ROUNDING_METHOD_TYPE, CASHOUT_AMT, CLTV, DEBT_RATIO, DISCOUNT_POINTS, FMAC_CONVERSION_IND, FREDDIE_MAC_IND, LATE_CHARGE_MAX_AMT, LATE_CHARGE_MIN_AMT, LATE_CHARGE_RATE, LIEN_TYPE, BOARDED_DATE, LOAN_PURCHASE_DATE, LTV, ORIGINAL_FUNDING_DATE, OTHER_FINANCE_AMT, PENDING_UNFUND_CANCEL_IND, PENDING_UNFUND_DATE, PROCEEDS, PREPAYMENT_EXPIRATION_DATE, PAYOFF_AMOUNT, PROGRAM, PROPERTY_RIGHTS_TYPE, LOAN_START_DATE, NUMBER_OF_PAYMENTS, ARM_INDEX, MARGIN, INTEREST_RATE, BROKER_ID, LOAN_AMOUNT, OLD_LOAN_NUMBER, MONTHLY_PAYMENT_AMOUNT, LC_GRACE_PERIOD, PROPERTY_ID, HOME_LOAN_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update LOAN_PARTY_MAPPING set HOME_LOAN_ID=? where HOME_LOAN_ID=? and PARTY_ID=? and PARTY_TYPE_CODE=?
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: dto.party.PersonDTO
at net.sf.hibernate.impl.SessionImpl.throwTransientObjectException(SessionImpl.java:2759)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2751)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:46)
at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:154)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:46)
at net.sf.hibernate.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:384)
at net.sf.hibernate.collection.Bag.writeTo(Bag.java:85)
at net.sf.hibernate.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:523)
at net.sf.hibernate.impl.ScheduledCollectionRecreate.execute(ScheduledCollectionRecreate.java:23)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2407)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2364)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2229)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at dao.impl.HomeLoanDAO.createLoan(HomeLoanDAO.java:84)
at dao.impl.TestHomeLoanDAO.testCreateLoan(TestHomeLoanDAO.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:172)
at com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
Exception: object references an unsaved transient instance - save the transient instance before flushing: party.PersonDTO
at dao.impl.HomeLoanDAO.createLoan(HomeLoanDAO.java:96)
at dao.impl.TestHomeLoanDAO.testCreateLoan(TestHomeLoanDAO.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:172)
at com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
Please let me know in case anybody has any clue.
Thanks,
Ramen
|