-->
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: unwanted fetching when inserting
PostPosted: Thu Feb 15, 2007 4:18 pm 
Newbie

Joined: Thu Feb 15, 2007 3:32 pm
Posts: 10
Hello

I have the following many-to-one entries in a hbm file
mapping file entries:
Code:
        <many-to-one name="tcProviderLookup" class="TcProviderLookup" fetch="select">
            <column name="TC_PROVIDER_CODE" precision="10" scale="0" not-null="true"/>
        </many-to-one>
        <many-to-one name="stateDistrictLookup" class="StateDistrictLookup"  insert="false" update="false" not-found="exception">
            <column name="STATE_DISTRICT_CODE" length="2"/>
        </many-to-one>
        <many-to-one name="suitNatureLookup" class="SuitNatureLookup" fetch="select">
            <column name="SUIT_NATURE_CODE" precision="10" scale="0"/>
        </many-to-one>
        <many-to-one name="dateTypeLookup" class="DateTypeLookup" fetch="select">
            <column name="FILED_DATE_TYPE_CODE" precision="3" scale="0"/>
        </many-to-one>
        <many-to-one name="documentKindLookup" class="DocumentKindLookup" fetch="select">
            <column name="DOC_KIND_CODE" precision="10" scale="0"/>
        </many-to-one>
        <many-to-one name="countyLookup" class="CountyLookup" fetch="select">
            <column name="COUNTY_CODE" precision="10" scale="0"/>
        </many-to-one>
        <many-to-one name="tcLabelLookup" class="TcLabelLookup" fetch="select">
            <column name="TC_LABEL_CODE" precision="10" scale="0"/>
        </many-to-one>
        <many-to-one name="memTabLookup" class="MemTabLookup" fetch="select">
            <column name="MEM_TAB_CODE" length="1"/>
        </many-to-one>


When I insert the record a fetch is executed for all of the many-to-one associations. I would assume this is trying to resolve whether the foreign key exists. Is there a way to let the database handle this - meaning I do not want to do all of this pre-fetching (see below) prior to the insert.


Hibernate SQL:
Code:
Hibernate:
    /* get current state com.west.mds.caselaw.TcProviderLookup */ select
        tcprovider_.TC_PROVIDER_CODE,
        tcprovider_.TC_PROVIDER_NAME as TC2_18_
    from
        MACHV.TC_PROVIDER_LOOKUP tcprovider_
    where
        tcprovider_.TC_PROVIDER_CODE=?
Hibernate:
    /* get current state com.west.mds.caselaw.StateDistrictLookup */ select
        statedistr_.STATE_DISTRICT_CODE,
        statedistr_.STATE_DISTRICT_DESC as STATE2_20_
    from
        MACHV.STATE_DISTRICT_LOOKUP statedistr_
    where
        statedistr_.STATE_DISTRICT_CODE=?
Hibernate:
    /* get current state com.west.mds.caselaw.SuitNatureLookup */ select
        suitnature_.SUIT_NATURE_CODE,
        suitnature_.SUIT_NATURE_DESC as SUIT2_32_
    from
        MACHV.SUIT_NATURE_LOOKUP suitnature_
    where
        suitnature_.SUIT_NATURE_CODE=?
Hibernate:
    /* get current state com.west.mds.caselaw.DateTypeLookup */ select
        datetypelo_.DATE_TYPE_CODE,
        datetypelo_.DATE_TYPE_TEXT as DATE2_31_
    from
        MACHV.DATE_TYPE_LOOKUP datetypelo_
    where
        datetypelo_.DATE_TYPE_CODE=?
Hibernate:
    /* get current state com.west.mds.caselaw.CountyLookup */ select
        countylook_.COUNTY_CODE,
        countylook_.STATE_DISTRICT_CODE as STATE2_19_,
        countylook_.US_DISTRICT_COURT_CODE as US3_19_,
        countylook_.COUNTY as COUNTY19_,
        countylook_.COUNTY_TERM as COUNTY5_19_,
        countylook_.COUNTY_TERM_CODE as COUNTY6_19_,
        countylook_.DISTRICT as DISTRICT19_,
        countylook_.DIVISION as DIVISION19_,
        countylook_.APPELLATE_COURT as APPELLATE9_19_
    from
        MACHV.COUNTY_LOOKUP countylook_
    where
        countylook_.COUNTY_CODE=?
Hibernate:
    /* get current state com.west.mds.caselaw.TcLabelLookup */ select
        tclabelloo_.TC_LABEL_CODE,
        tclabelloo_.TC_HEADING_CODE as TC2_15_,
        tclabelloo_.TC_LABEL as TC3_15_,
        tclabelloo_.TC_LABEL_SORT_NUMBER as TC4_15_
    from
        MACHV.TC_LABEL_LOOKUP tclabelloo_
    where
        tclabelloo_.TC_LABEL_CODE=?
Hibernate:
    /* get current state com.west.mds.caselaw.MemTabLookup */ select
        memtablook_.MEM_TAB_CODE,
        memtablook_.MEM_TAB_DESC as MEM2_14_
    from
        MACHV.MEM_TAB_LOOKUP memtablook_
    where
        memtablook_.MEM_TAB_CODE=?
Hibernate:
    /* insert com.west.mds.caselaw.DocumentFamily
        */ insert
        into
            MACHV.CASE
            (TC_PROVIDER_CODE, SUIT_NATURE_CODE, FILED_DATE_TYPE_CODE, DOC_KIND_CODE, COUNTY_CODE, TC_LABEL_CODE, MEM_TAB_CODE, SERIAL_NUMBER, ELECTRONIC_ID, FILED_DATE, RECORD_STATUS, APPENDIX_FLAG, BLOCKED_FLAG, SERIAL_CENTURY, REPLACING_SERIAL_NUMBER, ON_WESTLAW_FLAG, KEY_CITE_COLOR_CODE, INSTACITE_SUPPRESS_FLAG, ON_NORM_FLAG, TC_DOC_FLAG, FULL_TEXT_CODE, CREATE_USER, CREATE_DATE, MODIFY_USER, MODIFY_DATE, PATENT_APPLICATION_DATE, DMS_PUB_ID, CLIP_DATE, JUDGE, CLERK, PATENT_INVENTOR, PATENT_ASSIGNEE, NOTES, CONTEXT, LEGACY_ID, TC_DOC_HEADING, ADJUSTED_CITE_WORKFLOW_DATE, CASE_ABSTRACT_FLAG, CAUSE, CASE_UUID)
        values
            (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)


thanks,
Tom


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 12:01 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi PretzelLogic

try this way


<many-to-one name="suitNatureLookup" class="SuitNatureLookup" column="SUIT_NATURE_CODE" cascade="none" />

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 10:47 am 
Newbie

Joined: Thu Feb 15, 2007 3:32 pm
Posts: 10
Hi thanks for the suggestion - however - I'm still seeing the prefetch. Any other suggestion(s)?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 1:07 pm 
Newbie

Joined: Thu Feb 15, 2007 3:32 pm
Posts: 10
Thought I'd provide a bit more info.

Here is my POJO:

Code:
public class DocumentFamily
{
       // Fields
   private String caseUuid;
   private TcProviderLookup tcProviderLookup;
   private DocumentKindLookup documentKindLookup;
   private DateTypeLookup dateTypeLookup;
   private SuitNatureLookup suitNatureLookup;
   private StateDistrictLookup stateDistrictLookup;
   private CountyLookup countyLookup;
   private TcLabelLookup tcLabelLookup;

   private String appendixFlag;
   private String blockedFlag;
   private String onWestlawFlag;
   private String onNormFlag;
   private String tcDocFlag;
   private String caseAbstractFlag;

    public DocumentFamily()
    {
    }
     // full constructor omitted do to size limitations.

       public String getCaseUuid()
    {
        return caseUuid;
    }

    public void setCaseUuid(String caseUuid)
    {
        this.caseUuid = caseUuid;
    }

    public TcProviderLookup getTcProviderLookup()
    {
        return tcProviderLookup;
    }

    public void setTcProviderLookup(TcProviderLookup tcProviderLookup)
    {
        this.tcProviderLookup = tcProviderLookup;
    }

    public DocumentKindLookup getDocumentKindLookup()
    {
        return documentKindLookup;
    }

    public void setDocumentKindLookup(DocumentKindLookup documentKindLookup)
    {
        this.documentKindLookup = documentKindLookup;
    }

    public DateTypeLookup getDateTypeLookup()
    {
        return dateTypeLookup;
    }

    public void setDateTypeLookup(DateTypeLookup dateTypeLookup)
    {
        this.dateTypeLookup = dateTypeLookup;
    }

    public SuitNatureLookup getSuitNatureLookup()
    {
        return suitNatureLookup;
    }

    public void setSuitNatureLookup(SuitNatureLookup suitNatureLookup)
    {
        this.suitNatureLookup = suitNatureLookup;
    }

    public StateDistrictLookup getStateDistrictLookup()
    {
        return stateDistrictLookup;
    }

    public void setStateDistrictLookup(StateDistrictLookup stateDistrictLookup)
    {
        this.stateDistrictLookup = stateDistrictLookup;
    }

    public CountyLookup getCountyLookup()
    {
        return countyLookup;
    }

    public void setCountyLookup(CountyLookup countyLookup)
    {
        this.countyLookup = countyLookup;
    }

    public String getMemTabCode()
    {
        return memTabCode;
    }

    public void setMemTabCode(String memTabCode)
    {
        this.memTabCode = memTabCode;
    }

    public TcLabelLookup getTcLabelLookup()
    {
        return tcLabelLookup;
    }

    public void setTcLabelLookup(TcLabelLookup tcLabelLookup)
    {
        this.tcLabelLookup = tcLabelLookup;
    }

    public String getAppendixFlag()
    {
        return appendixFlag;
    }

    public void setAppendixFlag(String appendixFlag)
    {
        this.appendixFlag = appendixFlag;
    }

    public String getBlockedFlag()
    {
        return blockedFlag;
    }

    public void setBlockedFlag(String blockedFlag)
    {
        this.blockedFlag = blockedFlag;
    }

    public String getOnWestlawFlag()
    {
        return onWestlawFlag;
    }

    public void setOnWestlawFlag(String onWestlawFlag)
    {
        this.onWestlawFlag = onWestlawFlag;
    }

    public String getOnNormFlag()
    {
        return onNormFlag;
    }

    public void setOnNormFlag(String onNormFlag)
    {
        this.onNormFlag = onNormFlag;
    }

    public String getTcDocFlag()
    {
        return tcDocFlag;
    }

    public void setTcDocFlag(String tcDocFlag)
    {
        this.tcDocFlag = tcDocFlag;
    }

    public String getCaseAbstractFlag()
    {
        return caseAbstractFlag;
    }

    public void setCaseAbstractFlag(String caseAbstractFlag)
    {
        this.caseAbstractFlag = caseAbstractFlag;
    }
}


Here is mapping file:


Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jan 24, 2007 2:14:44 PM by Hibernate Tools 3.2.0.beta8 -->
<hibernate-mapping package="com.west.mds.caselaw">
    <class name="DocumentFamily" table="CASE">
        <id name="caseUuid" type="string">
            <column name="CASE_UUID" length="33"/>
            <generator class="assigned"/>
        </id>
        <many-to-one name="tcProviderLookup" class="TcProviderLookup" fetch="select">
            <column name="TC_PROVIDER_CODE" precision="10" scale="0" not-null="true"/>
        </many-to-one>
        <many-to-one name="stateDistrictLookup" class="StateDistrictLookup" not-null="true"  update="false">
            <column name="STATE_DISTRICT_CODE" length="2"/>
        </many-to-one>
        <many-to-one name="suitNatureLookup" class="SuitNatureLookup" fetch="select">
            <column name="SUIT_NATURE_CODE" precision="10" scale="0"/>
        </many-to-one>
        <many-to-one name="dateTypeLookup" class="DateTypeLookup" fetch="select">
            <column name="FILED_DATE_TYPE_CODE" precision="3" scale="0"/>
        </many-to-one>
        <many-to-one name="documentKindLookup" class="DocumentKindLookup" fetch="select">
            <column name="DOC_KIND_CODE" precision="10" scale="0"/>
        </many-to-one>
        <many-to-one name="countyLookup" class="CountyLookup" fetch="select">
            <column name="COUNTY_CODE" precision="10" scale="0"/>
        </many-to-one>
        <many-to-one name="tcLabelLookup" class="TcLabelLookup" fetch="select">
            <column name="TC_LABEL_CODE" precision="10" scale="0"/>
        </many-to-one>
        <many-to-one name="memTabLookup" class="MemTabLookup" fetch="select">
            <column name="MEM_TAB_CODE" length="1"/>
        </many-to-one>
        <property name="appendixFlag" type="string">
            <column name="APPENDIX_FLAG" length="1" not-null="true"/>
        </property>
        <property name="blockedFlag" type="string">
            <column name="BLOCKED_FLAG" length="1" not-null="true"/>
        </property>
        <property name="onWestlawFlag" type="string">
            <column name="ON_WESTLAW_FLAG" length="1" not-null="true"/>
        </property>
        <property name="onNormFlag" type="string">
            <column name="ON_NORM_FLAG" length="1" not-null="true"/>
        </property>
        <property name="tcDocFlag" type="string">
            <column name="TC_DOC_FLAG" length="1" not-null="true"/>
        </property>
        <property name="caseAbstractFlag" type="string">
            <column name="CASE_ABSTRACT_FLAG" length="1" not-null="true"/>
        </property>
    </class>
</hibernate-mapping>


How I'm using the objects in my code:
Code:
DocumentFamily documentFamily = new DocumentFamily();
            // set properties
            documentFamily.setAppendixFlag(buffer.toString());
            documentFamily.setBlockedFlag(buffer.toString());       
             ....
 
            // set many-to-one associations
            TcProviderLookup tcProviderLookup = new TcProviderLookup();
            tcProviderLookup.setTcProviderCode(new Long(buffer.toString()));
            documentFamily.setTcProviderLookup(tcProviderLookup);

            StateDistrictLookup stateDistrictLookup = new StateDistrictLookup();
            stateDistrictLookup.setStateDistrictCode(buffer.toString());
            documentFamily.setStateDistrictLookup(stateDistrictLookup);

            DateTypeLookup dateTypeLookup = new DateTypeLookup();
            dateTypeLookup.setDateTypeCode(new Integer(buffer.toString()));
            documentFamily.setDateTypeLookup(dateTypeLookup);

            CountyLookup countyLookup = new CountyLookup();
            countyLookup.setCountyCode(new Long(buffer.toString()));
            documentFamily.setCountyLookup(countyLookup);

            MemTabLookup memTabLookup = new MemTabLookup();
            memTabLookup.setMemTabCode(buffer.toString());
            documentFamily.setMemTabLookup(memTabLookup);

            TcLabelLookup tcLabel = new TcLabelLookup();
            tcLabel.setTcLabelCode(new Long(buffer.toString()));
            documentFamily.setTcLabelLookup(tcLabel);

            SuitNatureLookup suitNatureLookup = new SuitNatureLookup();
            suitNatureLookup.setSuitNatureCode(new Long(buffer.toString()));
            documentFamily.setSuitNatureLookup(suitNatureLookup);

                // make call to machv insert service
                ApplicationContext context = new ClassPathXmlApplicationContext("/xml/machv.context.xml");
                MachvService service = (MachvService) context.getBean("machvService");
                 
                // uses a dao object to call getHibernateTemplate.save()
                service.insert(documentFamily);


Please let me know if additional information would be useful.


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.