Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink-6024] - Exception Description: Modify queries require an object to modify.(Exception Description: Modify queries require an object to modify. Query: WriteObjectQuery(null))
EclipseLink-6024] - Exception Description: Modify queries require an object to modify. [message #1515013] Wed, 17 December 2014 20:05 Go to next message
gopi krishna is currently offline gopi krishnaFriend
Messages: 6
Registered: January 2014
Junior Member
EL throws
Exception [EclipseLink-6024] (Eclipse Persistence Services org.eclipse.persistence.exceptions.QueryException
Exception Description: Modify queries require an object to modify.
Query: WriteObjectQuery(null)

here is stack trace
Caused by: Exception [EclipseLink-6024] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Modify queries require an object to modify.
Query: InsertObjectQuery(null)
at org.eclipse.persistence.exceptions.QueryException.objectToModifyNotSpecified(QueryException.java:970)
at org.eclipse.persistence.queries.ObjectLevelModifyQuery.checkDescriptor(ObjectLevelModifyQuery.java:65)
at org.eclipse.persistence.queries.InsertObjectQuery.checkForCustomQuery(InsertObjectQuery.java:121)
at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:636)
at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)
at org.eclipse.persistence.mappings.AggregateCollectionMapping.getAndPrepareModifyQueryForInsert(AggregateCollectionMapping.java:2491)
at org.eclipse.persistence.mappings.AggregateCollectionMapping.preInsert(AggregateCollectionMapping.java:2443)
at org.eclipse.persistence.descriptors.DescriptorQueryManager.preInsert(DescriptorQueryManager.java:1093)
at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:439)
at org.eclipse.persistence.queries.InsertObjectQuery.executeCommit(InsertObjectQuery.java:80)
at org.eclipse.persistence.queries.InsertObjectQuery.executeCommitWithChangeSet(InsertObjectQuery.java:90)
at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:301)
at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:58)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:798)
at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:108)
at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:85)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1737)
at org.eclipse.persistence.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:226)
at org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:125)
at org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:4207)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1441)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1531)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:277)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1169)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:132)
... 2 more


So far coudln't find any solution for this error message. As message suggests, object to be inserted is NOT null.


thanks in advance.
Gopi
Re: EclipseLink-6024] - Exception Description: Modify queries require an object to modify. [message #1522702 is a reply to message #1515013] Mon, 22 December 2014 13:34 Go to previous messageGo to next message
Petros Splinakis is currently offline Petros SplinakisFriend
Messages: 12
Registered: September 2014
Junior Member
Hi Gopi,

Could you please provide some code sample where this exception occurs?
Ideally, could you provide a simple unit test demonstrating this error?
Re: EclipseLink-6024] - Exception Description: Modify queries require an object to modify. [message #1523161 is a reply to message #1522702] Mon, 22 December 2014 19:26 Go to previous messageGo to next message
gopi krishna is currently offline gopi krishnaFriend
Messages: 6
Registered: January 2014
Junior Member
Thanks for reply. As I mentioned in question: Its random. Same in put yields this error randomly. and code is regular code.

try {
txn = entityManager.getTransaction();
txn.begin();
for (int i = 0; i < objList.length; i ++) {
o = objList[i];
entityManager.persist(o);
}
txn.commit();
}
catch (Exception ex ) {
logger.error("Error persisting object : " + ex.getLocalizedMessage());
if(txn != null && txn.isActive())
txn.rollback();
}
Re: EclipseLink-6024] - Exception Description: Modify queries require an object to modify. [message #1524328 is a reply to message #1523161] Tue, 23 December 2014 11:13 Go to previous messageGo to next message
Petros Splinakis is currently offline Petros SplinakisFriend
Messages: 12
Registered: September 2014
Junior Member
I ran the following test for a while, managed to persist over 30.000 entities:

    @Test
    public void persistInLoopTest() {
        EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("PersistenceUnit");
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        EntityTransaction transaction = entityManager.getTransaction();
        int counter = 0;
        
        while (true) {
            Employee employee = new Employee();
            transaction.begin();
            try {
                entityManager.persist(employee);
                transaction.commit();
                Assert.assertTrue("Failed to persist employee", employee.getId() > 0);
                System.out.println("Persisted " + ++counter + " employees so far");
            } catch (Exception x) {
                if(transaction.isActive()) {
                    transaction.rollback();
                }
                Assert.fail("Error persisting employee: " + x.getMessage());
            }
        }
    }


Then I realized that you are using one transaction for the whole block, so I used the following:

    @Test
    public void persistInLoopSingleTransactionTest() {
        EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("PersistenceUnit");
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        EntityTransaction transaction = entityManager.getTransaction();
        transaction.begin();

        Employee employee = null;
        for(int i=0; i<100000; i++) {
            employee = new Employee();
            try {
                entityManager.persist(employee);
                Assert.assertTrue("Failed to persist employee", employee.getId() > 0);
                System.out.println("Persisted " + (i+1) + " employees so far");
            } catch (Exception x) {
                if(transaction.isActive()) {
                    transaction.rollback();
                }
                Assert.fail("Error persisting employee: " + x.getMessage());
            }
        }
        transaction.commit();

        entityManagerFactory.getCache().evictAll();
        EntityManager newEntityManager = entityManagerFactory.createEntityManager();
        Assert.assertNotNull("Employee not found in database", newEntityManager.find(Employee.class, employee.getId()));
    }


Could this be an issue with the application? Could you post a complete unit test demonstrating this?
Re: EclipseLink-6024] - Exception Description: Modify queries require an object to modify. [message #1548170 is a reply to message #1524328] Mon, 05 January 2015 21:55 Go to previous messageGo to next message
gopi krishna is currently offline gopi krishnaFriend
Messages: 6
Registered: January 2014
Junior Member
If I know when it is throwing exception, it would have been very easy to point reason. It happens randomly and as I mentioned, object we trying to persist is NOT null even during when error is thrown. Error is thrown when "transaction.commit();" is called. So out of some 20K objects we try to persist it randomly shows up this error. Sometimes it never occurs either.
Re: EclipseLink-6024] - Exception Description: Modify queries require an object to modify. [message #1551718 is a reply to message #1548170] Wed, 07 January 2015 20:06 Go to previous messageGo to next message
gopi krishna is currently offline gopi krishnaFriend
Messages: 6
Registered: January 2014
Junior Member
I am looking at the code of ObjectLevelModifyQuery.java
if (this.descriptor == null) {
if (getObject() == null) {
throw QueryException.objectToModifyNotSpecified(this);
}
Under what conditions getObject() OR (
/* The object being modified. */
protected Object object;
) is set to null? Apparently it is not null ALL the time. I have to run few times to get this error with exact same data and same output.

Gopi Putty





Re: EclipseLink-6024] - Exception Description: Modify queries require an object to modify. [message #1553422 is a reply to message #1551718] Thu, 08 January 2015 17:47 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
You might want to start by looking at the Entity being persisted and see if there is anything, such as references, which might cause issues later on. You might also turn on logging to see which objects are successful or make it easier to figure out which ones might be causing problems. Since this is inconsistent, and occurs on a very large transaction, it will be difficult to track down. I suspect that it will be something non-deterministic about how the instances are loaded and how they are processed by EclipseLink when determining changes.

Note that the exception stack mentions the issue is occuring when processing an aggregate object. You might want to check that your entities are not sharing aggregates, as this is not supported and causes odd problems - while this is the first I've seen this specific one, it wouldn't surprise me.

[Updated on: Thu, 08 January 2015 17:48]

Report message to a moderator

Re: EclipseLink-6024] - Exception Description: Modify queries require an object to modify. [message #1554903 is a reply to message #1553422] Fri, 09 January 2015 13:36 Go to previous message
gopi krishna is currently offline gopi krishnaFriend
Messages: 6
Registered: January 2014
Junior Member
Hi Chris,
Thanks for reply.
"I suspect that it will be something non-deterministic about how the instances are loaded and how they are processed by EclipseLink when determining changes. " - to avoid such cache issues, entitymanager is created every time and also evicting all cache wherever possible. and aggregates functions are not used. by the time objects ready for insert to db, its state is frozen.

thanks
Gopi Putty
Previous Topic:JMS Cache Coordination help with NON-JPA deployments
Next Topic:UUIDConverter and eclipselink 2.5.2
Goto Forum:
  


Current Time: Tue Mar 19 10:20:19 GMT 2024

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

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

Back to the top