-->
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: Problem Loading an Object
PostPosted: Fri Jan 09, 2004 7:30 pm 
Beginner
Beginner

Joined: Tue Nov 11, 2003 5:15 pm
Posts: 23
I have a Parent Object P and a Child object Q,
When I am loading an parent object, hibernate issues delete and insert sql for child object, why does hibernate treat this as a insert and delte?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 10, 2004 3:09 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Quote:
When I am loading an parent object, hibernate issues delete and insert sql for child object


I don't believe you;-). Show me your mappings, java code and Hibernate output.

Justin


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 11, 2004 12:32 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 5:15 pm
Posts: 23
This happens sporadically with different data, also note while loading jobposting object only for qual child object insert and delte sql is executed but not for parent object and not for another child costcenterset.

I have seen similar insert and delete problem many times when a boolean field has null value.
In this case when qualCategoryId which is of string type had null value,
when I manually updated the db with some value the load seems to work and it called insert and delete on qual object.

Even if there is something wrong with the mapping or with object, why would hibernate execute insert/delte, this is totally weird.

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

<!--
2003-12-17 Modified CustomField from Map to Set Mapping - Suresh
-->

<hibernate-mapping>

<class
name="insite.business.domain.cwm.JobPosting"
table="job_posting"
discriminator-value="0"
dynamic-insert="true"
dynamic-update="true">

<id name="id" type="string" column="job_posting_id">
<generator class="assigned"/>
</id>

<property name="requisitionId" type="string" column="requisition_id" not-null="true" length="14"/>
<property name="jobTemplateId" type="string" column="job_template_id" not-null="true" length="24"/>
<property name="ownerId" type="string" column="owner_id" not-null="true" length="24"/>
<property name="creatorId" type="string" column="creator_id" not-null="true" length="24"/>
<property name="buyerCode" type="string" column="buyer_code" not-null="true" length="4"/>
<property name="buId" type="string" column="bu_id" not-null="true" length="24"/>
<property name="externalRef" type="string" column="external_ref" length="100"/>
<property name="distributionListId" type="string" column="distribution_list_id" length="24"/>
<property name="coordinatorId" type="string" column="coordinator_id" length="24"/>
<property name="distributorId" type="string" column="distributor_id" length="24"/>
<property name="respondByDate" type="timestamp" column="respond_by_date" length="23"/>
<property name="distrTime" type="timestamp" column="distr_time" length="23"/>
<property name="positionsAvailable" type="integer" column="positions_available" not-null="true" length="10"/>
<property name="positionsFilled" type="integer" column="positions_filled" length="5"/>
<property name="comments" type="string" column="comments" length="1000"/>
<property name="title" type="string" column="title" not-null="true" length="100"/>
<property name="description" type="string" column="description" length="1000"/>
<property name="travelPct" type="big_decimal" column="travel_pct" length="9"/>
<property name="siteId" type="string" column="site_id" not-null="true" length="24"/>
<property name="hoursPerWeek" type="big_decimal" column="hours_per_week" length="13"/>
<property name="startDate" type="timestamp" column="start_date" not-null="true" length="23"/>
<property name="endDate" type="timestamp" column="end_date" not-null="true" length="23"/>
<property name="estOvertimePct" type="big_decimal" column="est_overtime_pct" length="9"/>
<property name="estExpensePct" type="big_decimal" column="est_expense_pct" length="9"/>
<property name="estSpend" type="big_decimal" column="est_spend" length="19"/>
<property name="currentDistributionLevel" type="integer" column="current_distribution_level" length="10"/>
<property name="maxDistributionLevel" type="integer" column="max_distribution_level" length="10"/>
<property name="lastDistrTime" type="timestamp" column="last_distr_time" length="23"/>
<property name="distributionPauseFlag" type="boolean" column="distribution_pause_flag" length="1"/>
<property name="distributionType" type="integer" column="distribution_type" not-null="true" length="10"/>
<property name="activeFlag" type="boolean" column="active_flag" length="1"/>
<property name="baseMarkupPct" type="big_decimal" column="base_markup_pct" length="9"/>
<property name="closedReasonId" type="string" column="closed_reason_id" length="24"/>
<property name="closedTime" type="timestamp" column="closed_time" length="23"/>
<property name="timeSheetType" type="integer" column="time_sheet_type" length="3"/>
<property name="jobPostingType" type="integer" column="job_posting_type" length="10"/>
<property name="jobTemplateType" type="integer" column="job_template_type" length="10"/>
<property name="hoursPerDay" type="big_decimal" column="hours_per_day" length="9"/>
<property name="billablePerDiem" type="big_decimal" column="billable_per_diem" length="13"/>
<property name="poNumber" type="string" column="po_number" length="30"/>
<property name="trialEndDate" type="timestamp" column="trial_end_date" length="23"/>
<property name="maxSubmission" type="integer" column="max_submission" length="10"/>
<property name="duration" type="integer" column="duration" length="10"/>
<property name="timeSheetFreq" type="integer" column="time_sheet_freq" length="3"/>
<property name="maxExpense" type="big_decimal" column="max_expense" length="13"/>
<property name="approvedTime" type="timestamp" column="approved_time" length="23"/>
<property name="revisionTime" type="timestamp" column="revision_time" length="23"/>
<property name="maxNumberOfBids" type="integer" column="max_number_of_bids" length="3"/>
<property name="bidStartTime" type="timestamp" column="bid_start_time" length="16"/>
<property name="bidEndTime" type="timestamp" column="bid_end_time" length="16"/>
<property name="jobSeekersInBid" type="integer" column="job_seekers_in_bid" length="3"/>
<property name="bidRespondByDate" type="timestamp" column="bid_respond_by_date" length="16"/>
<property name="rateUnit" type="string" column="rate_unit" length="3"/>
<property name="currency" type="string" column="currency" not-null="true" length="3"/>
<property name="serviceType" type="integer" column="service_type" length="3"/>
<property name="hireInvoiceTermsType" type="integer" column="hire_invoice_terms_type" length="3"/>
<property name="hireInvoiceTermsFeePct" type="big_decimal" column="hire_invoice_terms_fee_pct" length="3"/>
<property name="autoInvoiceType" type="integer" column="auto_invoice_type" length="3"/>
<property name="defaultOvertimeBillRateType" type="integer" column="default_overtime_bill_rate_type" length="10"/>

<component name="status" class="insite.business.domain.cwm.JobPostingStatus" insert="true" update="true">
<property name="state" type="integer" column="status" not-null="true" length="3"/>
</component>

<component name="rules" class="insite.business.domain.cwm.JobPostingRules" insert="true" update="true">
<property name="requirePinFlag" type="boolean" column="require_pin_flag" length="1"/>
<property name="tempToPermFlag" type="boolean" column="temp_to_perm_flag" length="1"/>
<property name="requireResumeFlag" type="boolean" column="require_resume_flag" length="1"/>
<property name="allowFinalRateChangeFlag" type="boolean" column="allow_final_rate_change_flag" length="1"/>
<property name="allowRateChangeFlag" type="boolean" column="allow_rate_change_flag" length="1"/>
<property name="workOrderCreationRule" type="integer" column="work_order_creation_rule" length="10"/>
<property name="workOrderExtensionCreationRule" type="integer" column="work_order_extension_creation_rule" length="10"/>
<property name="allowDistributorChangeFlag" type="boolean" column="allow_distributor_change_flag" length="1"/>
<property name="allowCoordinatorChangeFlag" type="boolean" column="allow_coordinator_change_flag" length="1"/>
<property name="autoEngageFlag" type="boolean" column="auto_engage_flag" length="1"/>
<property name="requirePayRateFlag" type="boolean" column="require_pay_rate_flag" length="1"/>
<property name="showPayRateToBuyerFlag" type="boolean" column="show_pay_rate_to_buyer_flag" length="1"/>
<property name="canCopyFlag" type="boolean" column="can_copy_flag" length="1"/>
<property name="showMarkupFlag" type="boolean" column="show_markup_flag" not-null="true" length="1"/>
<!-- <property name="autoInvoicingFlag" type="boolean" column="auto_invoicing_flag" length="1"/>-->
<property name="caTimeSheetRuleFlag" type="boolean" column="ca_time_sheet_rule_flag" length="1"/>
<property name="autoRegisterFlag" type="boolean" column="auto_register_flag" length="1"/>
<!-- <property name="trackTimeExpenseFlag" type="boolean" column="track_time_expense_flag" length="1"/>-->
<!-- <property name="canChangeHireTermsSchedule" type="boolean" column="can_change_hire_terms_schedule" length="1"/>-->
<property name="changeHireTermsScheduleFlag" type="boolean" column="change_hire_terms_schedule_flag" length="1"/>
<property name="visibilityToSupplierRule" type="integer" column="visibility_to_supplier_rule" length="3"/>
<property name="timeInHundredthsOfHoursFlag" type="boolean" column="time_in_hundredths_of_hours_flag" length="1"/>
<property name="titoInMilitaryFormatFlag" type="boolean" column="tito_in_military_format_flag" length="1"/>
<property name="editedByApproverFlag" type="boolean" column="edited_by_approver_flag" length="1"/>
<property name="stopApprovalOnExceedingBudgetFlag" type="boolean" column="stop_approval_on_exceeding_budget_flag" length="1"/>
</component>

<component name="baseRate" class="fieldglass.util.Rate">
<property name="rate" type="big_decimal" column="base_rate" length="9"/>
</component>
<component name="billRate" class="fieldglass.util.Rate">
<property name="rate" type="big_decimal" column="bill_rate" length="9"/>
</component>

<component name="overtimeRate" class="fieldglass.util.Rate">
<property name="rate" type="big_decimal" column="overtime_rate" length="9"/>
</component>

<component name="doubleTimeRate" class="fieldglass.util.Rate">
<property name="rate" type="big_decimal" column="double_time_rate" length="9"/>
</component>

<component name="minBaseRate" class="fieldglass.util.Rate">
<property name="rate" type="big_decimal" column="min_base_rate" length="9"/>
</component>

<component name="minSalary" class="fieldglass.util.Money">
<property name="amount" type="big_decimal" column="min_salary" length="9"/>
</component>

<component name="maxSalary" class="fieldglass.util.Money">
<property name="amount" type="big_decimal" column="max_salary" length="9"/>
</component>

<set name="costCenterSet" lazy="false" table="job_posting_cost_center" cascade="all">
<key column="job_posting_id"/>
<composite-element class="insite.business.domain.cwm.JobPostingCostCenter">
<property name="allocationPct" column="allocation_pct"/>
<property name="costCenterId" column="cost_center_id"/>
</composite-element>
</set>


<set name="qualSet" lazy="false" table="job_posting_qual" cascade="all">
<key column="job_posting_id"/>
<composite-element class="insite.business.domain.cwm.JobPostingQual">
<property name="qualId" type="string" column="qual_id" not-null="true"/>
<property name="scaleId" type="integer" column="scale_id" not-null="true"/>
<property name="mandatoryFlag" type="boolean" column="mandatory_flag" not-null="true"/>
<property name="rating" type="string" column="rating" not-null="true"/>
<property name="qualCategoryId" type="string" column="qual_category_id"/>
<property name="years" type="big_decimal" column="years"/>
<property name="valueFlag" type="boolean" column="value_flag"/>
</composite-element>
</set>


</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 1:12 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Whoaaa...
You need to break the example down to it's simplest form so that you can demonstrate the problem to us.
By simplest form I mean two classes, say JobPosting and JobPostingQual (with the minimal amount of properties that demonstrates the problem), the hibernate mappings and a simple main method that executes the code demonstrating the problem. Include the hibernate output in debug mode in your post.
(See the section on Isolate the problem at http://www.hibernate.org/160.html)

Currently I'm can't say what is happening. Perhaps a good starting point for you would be the section on Understanding Collection Performance in the hibernate reference manual.

Justin


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.