Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Unable to implement update for existing source object to point to existing target object

Hi Tom,

1. Yes I am invoking commit on UnitOfWork. I have set the log level to FINEST for the UnitOfWork. The SQL does not show up in the logs. The tables are hence not updated. The unit of work is in the end after printing the changes.
If I try to modify any direct to field mapping for the employee then that does show up in the change set. But if eclipselink calculates the changeset piecemeal (does it?), then like you said the change in the the one-to-many mapping may not show up in the changeset.


2. By modification of the list I meant:

List<DynamicEntity> empList = (DynamicEntity) dep.get("empinfo.depinfo");
empList.add(emp);

The introduction of the above code does not work. I am not even sure if the relationship on the other side "must" or "need not" be modified.

3. Yes I have the same mappings. Sorry I did not make it clear in the original question.

Department to Employee - one to many. 
Employee to Department - one to one.
The employee table has a foreign key constraint - depid.
join attribute is "empinfo.depinfo" for both the mappings.

Thanks and Regards
Member Technical Staff 
Oracle Server Technologies
91 80 41085685

----- Original Message -----
From: tom.ware@xxxxxxxxxx
To: rohit.banga@xxxxxxxxxx, eclipselink-users@xxxxxxxxxxx
Sent: Wednesday, January 5, 2011 12:27:21 AM GMT +05:30 Chennai, Kolkata, Mumbai, New Delhi
Subject: Re: [eclipselink-users] Unable to implement update for existing source object to point to existing target object

Hi Rohit,

   Do you actually commit your UnitOfWork?  i.e. are you seeing the problem at 
commit time through the absence of SQL, or are you simply getting the change set 
prior to commit?  If you are getting the change set prior to commit, the changes 
may simply not have been calculated yet.

   What do you mean by: "I have also tried to populate the list corresponding to 
the employees of  department 1010, but even that does not work."

   Please show where your unitOfWork.commit() calls are in the code you have 
included.

   Also, I assume these are the same mappings as you have shown in previous 
postings?


-Tom

Rohit Banga wrote:
>   Hi All
> 
> I have two tables
> 
> 1. Employee (id, name, depid)
> 2. Department (depid, depname)
> 
> I have created employee and department dynamic types. I have a OneToMany 
> relationship between the department and employee types.
> 
> I have to update the department of an employee. I am using the following 
> code:
> 
> DynamicEntity emp = helper.newDynamicEntity(empBuilder.getType().getName());
> emp.set("id", 147);
> emp = (DynamicEntity) unitOfWork.readObject(emp);
> 
> DynamicEntity dep = helper.newDynamicEntity(depBuilder.getType().getName());
> dep.set("depid", 1010);
> dep = (DynamicEntity) unitOfWork.readObject(dep);
> 
> emp.set("empinfo.depinfo", dep);
> 
> 
> However this does not update the depid for the employee row. The change 
> is not present in the change set for the unit of work.
> 
> The unit of work that I have acquired from the session does not contain 
> any objects before the readObject calls in the code above.
> 
> *Can you please tell me what is wrong with the above code?*
> 
> I have also tried to populate the list corresponding to the employees of 
> department 1010, but even that does not work.
> 
> *Is it mandatory to update the list or is it sufficient to modify the 
> emp object alone?*
> 
> When I use forceVersionUpdate for the emp object then, the session log 
> does show UpdateQuery in the logs however no update query is executed 
> against the database.
> *What is the reason for this behavior?*
> *
> *
> *Happy New Year!*
> *
> *
> Thanks
> Rohit Banga
> Member Technical Staff
> Oracle India Private Limited
> 91 80 41085685
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top