Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4(ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4)
ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4 [message #1771281] Wed, 23 August 2017 16:15 Go to next message
P Shetty is currently offline P ShettyFriend
Messages: 7
Registered: August 2017
Junior Member
We migrated our code from Toplink 9.0. to Eclipselink 2.6.4. We are using a project configuration xml which has all the mappings and we have the corresponding Java objects for the mappings as well. We are not using EclipseLink JPA. We are using Java 7 with Websphere Application Server 8.5.5

After migrating the code, the application was tested in lower environments and all seemed okay, but in Production we keep getting ConcurrentModificationException. This has led to CPU time of the JVM going up. We did not see this happen with Toplink 9.0 and have not yet been able to reproduce this error in lower environments.

This happens while using ReadObjectQuery with QueryExpression. Please advise. I have been unable to find anything related to this online.
Let me know if you need any more details from me.

Exception :

[8/7/17 11:12:58:747 CDT] 0000035f SystemOut O [EL Warning]: 2017-08-07 11:12:58.746--UnitOfWork(-565105113)--java.util.ConcurrentModificationException
[8/7/17 11:12:58:747 CDT] 0000035f BusinessExcep E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method

"getEnhancementInfoForOrderDetailLineItem" on bean "BeanId(TopLinkServicesHC#checks-hc-4.3.0.2.jar#HCCheckService, null)". Exception data:

java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:934)
at java.util.HashMap$ValueIterator.next(HashMap.java:962)
at org.eclipse.persistence.internal.identitymaps.IdentityMapKeyEnumeration.getNextCacheKey(IdentityMapKeyEnumeration.java:58)
at org.eclipse.persistence.internal.identitymaps.IdentityMapKeyEnumeration.hasMoreElements(IdentityMapKeyEnumeration.java:38)
at org.eclipse.persistence.internal.identitymaps.IdentityMapManager.getFromIdentityMap(IdentityMapManager.java:872)
at org.eclipse.persistence.internal.sessions.IdentityMapAccessor.getFromIdentityMap(IdentityMapAccessor.java:527)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.checkCacheForObject(ExpressionQueryMechanism.java:961)
at org.eclipse.persistence.queries.ReadObjectQuery.checkEarlyReturnLocal(ReadObjectQuery.java:260)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkEarlyReturn(ObjectLevelReadQuery.java:866)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:841)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1134)
at org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:441)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1222)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1857)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1839)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1790)
at com.harland.collective.eclipselink.database.EclipseLinkTransaction.getOne(EclipseLinkTransaction.java:861)
at com.harland.collective.eclipselink.database.EclipseLinkTransaction.getOne(EclipseLinkTransaction.java:799)
at com.harland.collective.eclipselink.database.EclipseLinkTransaction.getObject(EclipseLinkTransaction.java:778)
at com.harland.collective.eclipselink.database.AbstractDBManager.getObject(AbstractDBManager.java:575)
at com.harland.checks.server.bizservices.applicationcontrollers.AccessoryController.getAccessoryForCode(AccessoryController.java:1290)
at com.harland.checks.server.bizservices.applicationcontrollers.AccessoryController.getAccessoriesForCodes(AccessoryController.java:1261)
at com.harland.checks.server.EnhancementInfoBuilder.getEnhancementsForCodesNew(EnhancementInfoBuilder.java:472)


Code :
---------

AccessoryController.java :
-------------------------------
........
acc = (Accessory)dbMgr.getObject(
Accessory.class,
"accessoryItemCode",
catalogCode.toUpperCase());
.....

EclipseLinkTransaction.java:
--------------------------------------------
.....
public Object getOne(
Class objectClass,
String attributeName,
Object attributeValue)
throws IPDatabaseException
{
return getOne(
objectClass,
new QueryExpression[]
{
new QueryCompare(
attributeName,
QueryCompare.EQUAL,
attributeValue)
});
}


public Object getOne(Class objectClass, QueryExpression[] params)
throws IPDatabaseException
{
try
{
ReadObjectQuery query = new ReadObjectQuery();

query.setSelectionCriteria(getExpression(params));
query.setReferenceClass(objectClass);
query.checkCacheThenDatabase();

return getUow().executeQuery(query); ------- This is point in our code where eclipselink call triggers and we get a ConcurrentModification Exception
}
catch (DatabaseException exc)
{
throw new IPDatabaseException(exc.getMessage());
}
}
..........


Re: ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4 [message #1771399 is a reply to message #1771281] Thu, 24 August 2017 16:29 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1275
Registered: July 2009
Senior Member
TopLink 9 is.. dated so it is hard to tell what changed in particular when everything has changed. The error itself though seems likely due to reusing the same UnitOfWork session instance in multiple threads, as something is modifying the cache within the UOW while this query is iterating over it for the 'checkCache' part of the checkCacheThenDatabase() option. Any number of optimizations (or slowdowns in 'lower' systems) might prevent or cause it to occur in your production but not elsewhere, and tracking down timing issues are difficult in the best of times.

Your application should not be reusing a single UOW among multiple threads so I advise you to check out if this is a possibility or not. But short of turning on logging to show the thread and usage of the UOW, which generally slows things down, you might want to just work around this issue by setting the InMemoryQueryIndirectionPolicy.SHOULD_TRIGGER_INDIRECTION policy on the query. Since this option is stating the cache of registered objects will change, it makes a copy of the collection before iterating over it - a slight performance hit, but one that will avoid this concurrency exception. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=321041
Re: ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4 [message #1771631 is a reply to message #1771399] Mon, 28 August 2017 22:35 Go to previous messageGo to next message
P Shetty is currently offline P ShettyFriend
Messages: 7
Registered: August 2017
Junior Member
Thanks a lot for your response. I feel more hopeful now, as this is the first time I have found any kind of response to my issue in the last 2 months.
I am not a 100% sure if a single instance of UOW is used across multiple threads. The code is old and complex to figure this out easily. I will try to see if I can debug this piece, but most likely I would think that's not the case as it worked in Toplink. And even if so, did you mean the alternative to this would be to use InMemoryQueryIndirectionPolicy.SHOULD_TRIGGER_INDIRECTION for the query? What does InMemoryQueryIndirectionPolicy.SHOULD_TRIGGER_INDIRECTION actually do? I tried to search online, but did not get much information. Since I am unable to reproduce in the lower environments, I want to be clear what I am doing and that there are no more surprises in Production.

The bug listing that you had attached has this in the code -
q.conformResultsInUnitOfWork();
q.setInMemoryQueryIndirectionPolicyState(InMemoryQueryIndirectionPolicy.SHOULD_TRIGGER_INDIRECTION);

What is q.conformResultsInUnitOfWork(); ? Is it required? Do I need to use that along with the line that uses InMemoryQueryIndirectionPolicy.SHOULD_TRIGGER_INDIRECTION?

Also, am I right in understanding that this is the line that's causing an issue ?
query.checkCacheThenDatabase();

If so, I am wondering if I could comment that ? Would it cause performance issues?

Thanks again for you help.
Re: ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4 [message #1771687 is a reply to message #1771631] Tue, 29 August 2017 14:11 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1275
Registered: July 2009
Senior Member
Short of going over the entire project, I can't really comment on what performance issues adding more settings or removing them will cause. They do have an effect though, and that effect depends on the entities involved.

checkCacheThenDatabase is an option that tells EclipseLink to iterate over the cache to check for results before going to the database. It can avoid a database hit, but performance depends on the cache size and the query.

conformResultsInUnitOfWork works on the reverse side. When results are obtained from the DB or shared cache, the query will obtain the object from the UOW cache. This option causes EclipseLink to then check that object to see if it still matches the query filters - any changes made on this object in the UOW might not be in the database yet.

SHOULD_TRIGGER_INDIRECTION tells EclipseLink what to do when looking at objects in the cache for any of these query cache checks and finding untriggered/lazy relationships. For instance, if your query were over "employee.phoneNumber.areacode = '613'", and some employee object in the cache didn't have the PhoneNumber fetched. The SHOULD_TRIGGER_INDIRECTION specifically tells EclipseLink to hit the database to fetch and build this phonenumber. Its cost directly depends on the query - if it doesn't span a relationship, the only cost should be the collection cloning.

See
https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Caching/Query_Options#JPA_Cache_Query_Hints
for a brief description. The docs have better descriptions, I just don't have links handy.
Re: ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4 [message #1771721 is a reply to message #1771687] Tue, 29 August 2017 20:59 Go to previous messageGo to next message
P Shetty is currently offline P ShettyFriend
Messages: 7
Registered: August 2017
Junior Member
Thanks again for your response. Now, that you mentioned this about SHOULD_TRIGGER_INDIRECTION , I am wondering if all the relationships of Accessory.java will be triggered by doing this. My query is based on direct field value 'accessoryItemCode' in the Accessory object. Would using SHOULD_TRIGGER_INDIRECTION also trigger all the other relationships in Accessory.java and clone the entire Accessory object with all indirections resolved? Or it just makes a copy of the collection, but does not resolve other indirections since it is not required for 'accessoryItemCode=somevalue" query expression

Please advise.

This is what I have in my code -

IDBManager dbMgr = DBManagerFactory.getInstance().getDBManager();

acc = (Accessory)dbMgr.getObject(
Accessory.class,
"accessoryItemCode",
codeForSearch);

In Accessory.java , accessoryItemCode is a String , but it also has several other relationship objects which are one-many, one-one and there is also one of the many-many kind.

private String accessoryItemCode;

public Accessory()
    {
        accessoryListTypesHolder = new ValueHolder(new Vector());
        accyComponentsHolder = new ValueHolder(new Vector());
        defaultCatalogAssemblyHolder = new ValueHolder();
        catalogAssembliesHolder = new ValueHolder(new Vector());
        defaultFontHolder = new ValueHolder();
        logoImageHolder = new ValueHolder();
        apCheckFeatureHolder = new ValueHolder(new Vector());
        accCompImageViewHolder = new ValueHolder(new Vector());
        optionValuesHolder = new ValueHolder(new Vector());
    }
   
    public void setAccessoryItemCode(String code)
    {
        accessoryItemCode = code;
    }

    public String getAccessoryItemCode()
    {
        return accessoryItemCode;
    }



Attaching the descriptor for the Accessory object.

<class-mapping-descriptor xsi:type="relational-class-mapping-descriptor">
         <class>com.harland.checks.server.businessobjects.product.Accessory</class>
         <alias>Accessory</alias>
         <primary-key>
            <field table="p_accessory" name="accessory_id" xsi:type="column"/>
         </primary-key>
         <events xsi:type="event-policy"/>
         <querying xsi:type="query-policy"/>
         <attribute-mappings>
            <attribute-mapping xsi:type="one-to-many-mapping">
               <attribute-name>accCompImageViewHolder</attribute-name>
               <read-only>true</read-only>
               <get-method>getAccCompImageViewHolder</get-method>
               <set-method>setAccCompImageViewHolder</set-method>
               <reference-class>com.harland.checks.server.businessobjects.product.AccCompImageView</reference-class>
               <target-foreign-key>
                  <field-reference>
                     <source-field table="hc_acc_compimg_view" name="accessory_id" xsi:type="column"/>
                     <target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
                  </field-reference>
               </target-foreign-key>
               <batch-reading>true</batch-reading>
               <container xsi:type="list-container-policy">
                  <collection-type>java.util.Vector</collection-type>
               </container>
               <indirection xsi:type="value-holder-indirection-policy"/>
               <selection-query xsi:type="read-all-query">
                  <container xsi:type="list-container-policy">
                     <collection-type>java.util.Vector</collection-type>
                  </container>
               </selection-query>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>accessoryId</attribute-name>
               <get-method>getAccessoryId</get-method>
               <set-method>setAccessoryId</set-method>
               <field table="p_accessory" name="accessory_id" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>accessoryItemCode</attribute-name>
               <get-method>getAccessoryItemCode</get-method>
               <set-method>setAccessoryItemCode</set-method>
               <field table="p_accessory" name="hc_accessory_code" xsi:type="column"/>
            </attribute-mapping>
			<attribute-mapping xsi:type="direct-mapping">
               <attribute-name>replacedAccessoryItemCode</attribute-name>
               <get-method>getReplacedAccessoryItemCode</get-method>
               <set-method>setReplacedAccessoryItemCode</set-method>
               <field table="p_accessory" name="accessory_code" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="one-to-many-mapping">
               <attribute-name>accessoryListTypesHolder</attribute-name>
               <get-method>getAccessoryListTypesHolder</get-method>
               <set-method>setAccessoryListTypesHolder</set-method>
               <reference-class>com.harland.checks.server.businessobjects.product.AccessoryListTypeAccLink</reference-class>
               <private-owned>true</private-owned>
               <target-foreign-key>
                  <field-reference>
                     <source-field table="acclisttypeacc_lk" name="acc_uid" xsi:type="column"/>
                     <target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
                  </field-reference>
               </target-foreign-key>
               <container xsi:type="list-container-policy">
                  <collection-type>java.util.Vector</collection-type>
               </container>
               <indirection xsi:type="value-holder-indirection-policy"/>
               <selection-query xsi:type="read-all-query">
                  <container xsi:type="list-container-policy">
                     <collection-type>java.util.Vector</collection-type>
                  </container>
               </selection-query>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>accessoryOptionDescription</attribute-name>
               <get-method>getAccessoryOptionDescription</get-method>
               <set-method>setAccessoryOptionDescription</set-method>
               <field table="p_accessory" name="acc_option_desc" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>accessoryType</attribute-name>
               <get-method>getAccessoryType</get-method>
               <set-method>setAccessoryType</set-method>
               <field table="p_accessory" name="accessory_type" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="many-to-many-mapping">
               <attribute-name>accyComponentsHolder</attribute-name>
               <read-only>true</read-only>
               <get-method>getAccyComponentsHolder</get-method>
               <set-method>setAccyComponentsHolder</set-method>
               <reference-class>com.harland.checks.server.businessobjects.product.AbstractComponent</reference-class>
               <relation-table>p_accessory_comp</relation-table>
               <source-relation-foreign-key>
                  <field-reference>
                     <source-field table="p_accessory_comp" name="accessory_id" xsi:type="column"/>
                     <target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
                  </field-reference>
               </source-relation-foreign-key>
               <target-relation-foreign-key>
                  <field-reference>
                     <source-field table="p_accessory_comp" name="component_id" xsi:type="column"/>
                     <target-field table="p_component" name="component_id" xsi:type="column"/>
                  </field-reference>
               </target-relation-foreign-key>
               <container xsi:type="list-container-policy">
                  <collection-type>java.util.Vector</collection-type>
               </container>
               <indirection xsi:type="value-holder-indirection-policy"/>
               <selection-query xsi:type="read-all-query">
                  <container xsi:type="list-container-policy">
                     <collection-type>java.util.Vector</collection-type>
                  </container>
               </selection-query>
               <insert-query xsi:type="data-modify-query"/>
               <delete-query xsi:type="data-modify-query"/>
               <delete-all-query xsi:type="data-modify-query"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="one-to-many-mapping">
               <attribute-name>apCheckFeatureHolder</attribute-name>
               <get-method>getAPCheckFeatureHolder</get-method>
               <set-method>setAPCheckFeatureHolder</set-method>
               <reference-class>com.harland.checks.server.businessobjects.product.CheckFeature</reference-class>
               <private-owned>true</private-owned>
               <target-foreign-key>
                  <field-reference>
                     <source-field table="check_feature" name="accessory_id" xsi:type="column"/>
                     <target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
                  </field-reference>
               </target-foreign-key>
               <container xsi:type="list-container-policy">
                  <collection-type>java.util.Vector</collection-type>
               </container>
               <indirection xsi:type="value-holder-indirection-policy"/>
               <selection-query xsi:type="read-all-query">
                  <container xsi:type="list-container-policy">
                     <collection-type>java.util.Vector</collection-type>
                  </container>
               </selection-query>
            </attribute-mapping>
            <attribute-mapping xsi:type="one-to-many-mapping">
               <attribute-name>catalogAssembliesHolder</attribute-name>
               <get-method>getCatalogAssembliesHolder</get-method>
               <set-method>setCatalogAssembliesHolder</set-method>
               <reference-class>com.harland.checks.server.businessobjects.product.CatalogAssembly</reference-class>
               <target-foreign-key>
                  <field-reference>
                     <source-field table="p_catalog" name="accessory_id" xsi:type="column"/>
                     <target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
                  </field-reference>
               </target-foreign-key>
               <container xsi:type="list-container-policy">
                  <collection-type>java.util.Vector</collection-type>
               </container>
               <indirection xsi:type="value-holder-indirection-policy"/>
               <selection-query xsi:type="read-all-query">
                  <container xsi:type="list-container-policy">
                     <collection-type>java.util.Vector</collection-type>
                  </container>
               </selection-query>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>checkmarkAllowedStr</attribute-name>
               <field table="p_accessory" name="checkmarkallowed" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="one-to-one-mapping">
               <attribute-name>defaultCatalogAssemblyHolder</attribute-name>
               <get-method>getDefaultCatalogAssemblyHolder</get-method>
               <set-method>setDefaultCatalogAssemblyHolder</set-method>
               <reference-class>com.harland.checks.server.businessobjects.product.CatalogAssembly</reference-class>
               <foreign-key>
                  <field-reference>
                     <source-field table="p_accessory" name="catalog_id" xsi:type="column"/>
                     <target-field table="p_catalog" name="catalog_id" xsi:type="column"/>
                  </field-reference>
               </foreign-key>
               <foreign-key-fields>
                  <field table="p_accessory" name="catalog_id" xsi:type="column"/>
               </foreign-key-fields>
               <indirection xsi:type="value-holder-indirection-policy"/>
               <selection-query xsi:type="read-object-query"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="one-to-one-mapping">
               <attribute-name>defaultFontHolder</attribute-name>
               <get-method>getDefaultFontHolder</get-method>
               <set-method>setDefaultFontHolder</set-method>
               <reference-class>com.harland.checks.server.businessobjects.product.Accessory</reference-class>
               <foreign-key>
                  <field-reference>
                     <source-field table="p_accessory" name="font_accessory_id" xsi:type="column"/>
                     <target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
                  </field-reference>
               </foreign-key>
               <foreign-key-fields>
                  <field table="p_accessory" name="font_accessory_id" xsi:type="column"/>
               </foreign-key-fields>
               <indirection xsi:type="value-holder-indirection-policy"/>
               <selection-query xsi:type="read-object-query"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>effectiveDate</attribute-name>
               <get-method>getEffectiveDate</get-method>
               <set-method>setEffectiveDate</set-method>
               <field table="p_accessory" name="eff_dt" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>expirationDate</attribute-name>
               <get-method>getExpirationDate</get-method>
               <set-method>setExpirationDate</set-method>
               <field table="p_accessory" name="exp_dt" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>initialAllowedStr</attribute-name>
               <field table="p_accessory" name="initialallowed" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>licenseInfo</attribute-name>
               <get-method>getLicenseInfo</get-method>
               <set-method>setLicenseInfo</set-method>
               <field table="p_accessory" name="lisc_info" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="one-to-one-mapping">
               <attribute-name>logoImageHolder</attribute-name>
               <get-method>getLogoImageHolder</get-method>
               <set-method>setLogoImageHolder</set-method>
               <reference-class>com.harland.checks.server.businessobjects.product.ImageReference</reference-class>
               <foreign-key>
                  <field-reference>
                     <source-field table="p_accessory" name="logo_image_id" xsi:type="column"/>
                     <target-field table="p_image" name="image_id" xsi:type="column"/>
                  </field-reference>
               </foreign-key>
               <indirection xsi:type="value-holder-indirection-policy"/>
               <selection-query xsi:type="read-object-query"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>longDescription</attribute-name>
               <get-method>getLongDescription</get-method>
               <set-method>setLongDescription</set-method>
               <field table="p_accessory" name="hc_long_desc" xsi:type="column"/>
            </attribute-mapping>
			<attribute-mapping xsi:type="direct-mapping">
               <attribute-name>replacedLongDescription</attribute-name>
               <get-method>getReplacedLongDescription</get-method>
               <set-method>setReplacedLongDescription</set-method>
               <field table="p_accessory" name="long_desc" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>miscInfo</attribute-name>
               <get-method>getMiscInfo</get-method>
               <set-method>setMiscInfo</set-method>
               <field table="p_accessory" name="misc_info" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>monogramRequiredStr</attribute-name>
               <field table="p_accessory" name="monogramrequired" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="many-to-many-mapping">
               <attribute-name>optionValuesHolder</attribute-name>
               <get-method>getOptionValuesHolder</get-method>
               <set-method>setOptionValuesHolder</set-method>
               <reference-class>com.harland.checks.server.businessobjects.product.AccessoryOptionValue</reference-class>
               <relation-table>acc_option_val_lk</relation-table>
               <source-relation-foreign-key>
                  <field-reference>
                     <source-field table="acc_option_val_lk" name="accessory_id" xsi:type="column"/>
                     <target-field table="p_accessory" name="accessory_id" xsi:type="column"/>
                  </field-reference>
               </source-relation-foreign-key>
               <target-relation-foreign-key>
                  <field-reference>
                     <source-field table="acc_option_val_lk" name="acc_option_val_id" xsi:type="column"/>
                     <target-field table="acc_option_value" name="uid" xsi:type="column"/>
                  </field-reference>
               </target-relation-foreign-key>
               <container xsi:type="list-container-policy">
                  <collection-type>java.util.Vector</collection-type>
               </container>
               <indirection xsi:type="value-holder-indirection-policy"/>
               <selection-query xsi:type="read-all-query">
                  <container xsi:type="list-container-policy">
                     <collection-type>java.util.Vector</collection-type>
                  </container>
               </selection-query>
               <insert-query xsi:type="data-modify-query"/>
               <delete-query xsi:type="data-modify-query"/>
               <delete-all-query xsi:type="data-modify-query"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>shortDescription</attribute-name>
               <get-method>getShortDescription</get-method>
               <set-method>setShortDescription</set-method>
               <field table="p_accessory" name="hc_short_desc" xsi:type="column"/>
            </attribute-mapping>
			<attribute-mapping xsi:type="direct-mapping">
               <attribute-name>replacedShortDescription</attribute-name>
               <get-method>getReplacedShortDescription</get-method>
               <set-method>setReplacedShortDescription</set-method>
               <field table="p_accessory" name="short_desc" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>supportedBinding</attribute-name>
               <get-method>getSupportedBinding</get-method>
               <set-method>setSupportedBinding</set-method>
               <field table="p_accessory" name="supported_binding" xsi:type="column"/>
            </attribute-mapping>
            <attribute-mapping xsi:type="direct-mapping">
               <attribute-name>teamNameRequiredStr</attribute-name>
               <field table="p_accessory" name="teamnamerequired" xsi:type="column"/>
            </attribute-mapping>
         </attribute-mappings>
         <descriptor-type>independent</descriptor-type>
         <locking xsi:type="version-locking-policy">
            <version-field table="p_accessory" name="lock_version" xsi:type="column"/>
         </locking>
         <sequencing>
            <sequence-name>p_accessory</sequence-name>
            <sequence-field table="p_accessory" name="accessory_id" xsi:type="column"/>
         </sequencing>
         <instantiation/>
         <copying xsi:type="instantiation-copy-policy"/>
         <change-policy xsi:type="deferred-detection-change-policy"/>
         <tables>
            <table name="p_accessory"/>
         </tables>
      </class-mapping-descriptor>



I also had another question :-
Can I catch the ConcurrentModificationException? Is it alright to do so and if so, how can I capture something useful in the catch section? Would something like session.getIdentityMapAccessor().printIdentityMap(Accessory.class) help ? I was wondering if that will affect performance even more.
Re: ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4 [message #1771791 is a reply to message #1771721] Wed, 30 August 2017 14:36 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1275
Registered: July 2009
Senior Member
SHOULD_TRIGGER_INDIRECTION tells EclipseLink what to do when it encounters an untriggered lazy relationship when trying to determine if the cached object matches the query's filter. It should be clear in the context of the other options that this is only in accessing the parts of the cached object it needs to in order to determine if it satisfies the query - it will not trigger all lazy relationships in your objects unless your query criteria requires it to. In the employee.phonenumbers.value expression reference, only the employee's phonenumbers reference would be triggered when needed.
Re: ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4 [message #1771869 is a reply to message #1771791] Thu, 31 August 2017 14:03 Go to previous messageGo to next message
P Shetty is currently offline P ShettyFriend
Messages: 7
Registered: August 2017
Junior Member
Thank you Chris!
I will add the SHOULD_TRIGGER_INDIRECTION to my code.

Can you please tell me how to use either of these? -

'session.getIdentityMapAccessor().printIdentityMap(Accessory.class)
session.getIdentityMapAccessor().printIdentityMaps()
session.getIdentityMapAccessor.printIdentityMapLocks()

Should it go in the catch of the try-catch block? Or should it be in the try block and it executes and prints out only when there is an error? Do you think it is helpful in my scenario?

try
{
ReadObjectQuery query = new ReadObjectQuery();

query.setSelectionCriteria(getExpression(params));
query.setReferenceClass(objectClass);
query.checkCacheThenDatabase();

return getUow().executeQuery(query); ------- This is point in our code where eclipselink call triggers and we get a ConcurrentModification Exception
}
catch (DatabaseException exc)
{
throw new IPDatabaseException(exc.getMessage());
}
catch (Exception ex)
{
}
Re: ConcurrentModificationException using ReadObjectquery with EclipseLink 2.6.4 [message #1773412 is a reply to message #1771869] Wed, 27 September 2017 15:05 Go to previous message
P Shetty is currently offline P ShettyFriend
Messages: 7
Registered: August 2017
Junior Member
Hi Chris,
Your solution of using query.setInMemoryQueryIndirectionPolicyState(InMemoryQueryIndirectionPolicy.SHOULD_TRIGGER_INDIRECTION); took care of the ConcurrentModificationException issue. I figured we were not using different UoW for each thread, but that's how it was when we used Toplink 9.0 and it worked fine. Making the change to use differnt UoW for each thread is going to be big. Meanwhile, your solution above fixed the problem in Production. Thanks! Appreciate your help and responses to my queries.
Previous Topic:Recovering from connection exceeded time limit
Next Topic:Performance problem when doing merge
Goto Forum:
  


Current Time: Sat Dec 16 20:38:30 GMT 2017

Powered by FUDForum. Page generated in 0.04142 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software