Uow.copyObject problem

Dear all,
I have used uow.copyObject for the following scenario, but find a problem.
Object ParentA aggregate many --> Object ChildB
aggregate many --> Object ChildC
Object ChildB normal reference one of Object ChildC.
My expected result if copyObject(Object ParentA, privatedOwned) is
Object ParentACopied aggregate many --> Object ChildBCopied
aggregate many --> Object ChildCCopied
Object ChildBCopyied normal reference one of Object ChildCCopied
But the actual result comes up is
Object ParentACopied aggregate many --> Object ChildBCopied
aggregate many --> Object ChildCCopied
Object ChildBCopyied normal reference one of Object ChildC
Would like to know if it is an normal behavior and is there any workaround in order to have my expected result

I'm not sure I understand you issue,
you have A -aggregate-collection-> B -aggregate-collection-> C
And when using a copyObject, the copy contains copies of A and B, but not C? Or does the copy contain copies of A and B and C, but some other references to C from B not referring to the copy?
How is this reference mapped? and what depth did you specify for the copy?
There are three copy depth, shallow, normal (only copies private-owned relationships), deep. You may need to use a deep copy if the reference is not mapped as private-owned.

Similar Messages

  • CopyObject(Object) method

    What are the differences b/w clientSession.copyObject(o) and uow.copyObject(o) ? And their usages... Is it common to use uow.copyObject(o)?
    Thanks for your information.
    Haiwei

    Haiwei,
    All of the TopLink sessions, including the UnitOfwork, implement the oracle.toplink.sessions.Session interface. This is a method of that interface and shared a common implementation between all of the public concrete implementations. There should no difference in calling copyObject on any session.
    Doug

  • TopLink Proxy Indirection problem when comitting uow

    We are trying to introduce the use of TopLink proxy indirection into our object model.
    We have run into situations where the uow cannot be committed because proxy indirection is being encountered.
    (See the stack trace provided below).
    What do we need to be aware of and what actions should we take to make it over this hurdle?
    Would ValueHolder cause the same problem, or would TopLink be better able to handle ValueHolder indirection than Proxy Indirection?
    Thanks for any help/hints guidance you can provide.
    2004.09.21 06:09:51.406--UnitOfWork(2820596)--Thread[ExecuteThread: '12' for queue: 'default',5,Thread Group for Queue: 'default']--Before JTS Completion
    2004.09.21 06:09:51.437--UnitOfWork(2820596)--Thread[ExecuteThread: '12' for queue: 'default',5,Thread Group for Queue: 'default']--Exception [TOPLINK-7009] (OracleAS TopLink - 10g (9.0.4.1) (Build 040128)): oracle.toplink.exceptions.ValidationException
    Exception Description: Missing descriptor for [$Proxy98]. Verify that the descriptor has been properly registered with the Session.Local Exception Stack:
    Exception [TOPLINK-7009] (OracleAS TopLink - 10g (9.0.4.1) (Build 040128)): oracle.toplink.exceptions.ValidationException
    Exception Description: Missing descriptor for [$Proxy98]. Verify that the descriptor has been properly registered with the Session.
         at oracle.toplink.exceptions.ValidationException.missingDescriptor(ValidationException.java:599)
         at oracle.toplink.internal.descriptors.DescriptorIterator.getDescriptorFor(DescriptorIterator.java:86)
         at oracle.toplink.internal.descriptors.DescriptorIterator.iterateReferenceObjectForMapping(DescriptorIterator.java:242)
         at oracle.toplink.mappings.ObjectReferenceMapping.iterateOnRealAttributeValue(ObjectReferenceMapping.java:267)
         at oracle.toplink.internal.indirection.IndirectionPolicy.iterateOnAttributeValue(IndirectionPolicy.java:186)
         at oracle.toplink.mappings.ForeignReferenceMapping.iterate(ForeignReferenceMapping.java:503)
         at oracle.toplink.internal.descriptors.ObjectBuilder.iterate(ObjectBuilder.java:1436)
         at oracle.toplink.internal.descriptors.DescriptorIterator.iterateReferenceObjects(DescriptorIterator.java:258)
         at oracle.toplink.internal.descriptors.DescriptorIterator.iterateReferenceObjectForMapping(DescriptorIterator.java:250)
         at oracle.toplink.mappings.ObjectReferenceMapping.iterateOnRealAttributeValue(ObjectReferenceMapping.java:267)
         at oracle.toplink.internal.indirection.IndirectionPolicy.iterateOnAttributeValue(IndirectionPolicy.java:186)
         at oracle.toplink.mappings.ForeignReferenceMapping.iterate(ForeignReferenceMapping.java:503)
         at oracle.toplink.internal.descriptors.ObjectBuilder.iterate(ObjectBuilder.java:1436)
         at oracle.toplink.internal.descriptors.DescriptorIterator.iterateReferenceObjects(DescriptorIterator.java:258)
         at oracle.toplink.internal.descriptors.DescriptorIterator.startIterationOn(DescriptorIterator.java:407)
         at oracle.toplink.publicinterface.UnitOfWork.discoverUnregisteredNewObjects(UnitOfWork.java:1361)
         at oracle.toplink.publicinterface.UnitOfWork.discoverAllUnregisteredNewObjects(UnitOfWork.java:1283)
         at oracle.toplink.publicinterface.UnitOfWork.assignSequenceNumbers(UnitOfWork.java:325)
         at oracle.toplink.publicinterface.UnitOfWork.collectAndPrepareObjectsForCommit(UnitOfWork.java:659)
         at oracle.toplink.publicinterface.UnitOfWork.commitToDatabaseWithChangeSet(UnitOfWork.java:1123)
         at oracle.toplink.publicinterface.UnitOfWork.issueSQLbeforeCompletion(UnitOfWork.java:2465)
         at oracle.toplink.jts.AbstractSynchronizationListener.beforeCompletion(AbstractSynchronizationListener.java:151)
         at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:540)
         at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:92)
         at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:1044)
         at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:1581)
         at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:237)
         at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:208)
         at weblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManagerImpl.java:282)

    Hello,
    Could you tell me a little more about what you are trying to do? From the stacktrace it appears that TopLink is searching for all new objects and finding a proxy, and doesn't know that it is uninstantiated.
    Could you show me the piece of code where your unit of work registers and commits this object?

  • Problem with UoW registerNewObject

    Hello,
    In our system, a web client passes objects that we need to merge into a UoW.
    The objects were previously detached from the UoW.
    We merge existing (updated) objects into the UoW and that works fine.
    We are using JPA (EclipseLink 1.1.2) and have the primary unique identifier generated from an Oracle database sequence.
    For new objects we tried UoW.registerNewObject. In that case however, an ID is not generated when the object is persisted, resulting in an ORA-1400 error thrown by the database (cannot insert null into).
    The insert statement is generated correctly, but the 'select REL_COUNTRIES_S1.nextval from dual' statement is not executed prior to that.
    Did someone else encounter this problem?
    Should we use a different way to register / merge new objects into the UoW?
    Thanks. Best regards,
    - Sjoerd

    Hi Vinay,
    Thanks for the reply.
    The entity for this case is the following, it works fine in all other use case scenarios.
    @Entity
    @Table(name = "REL_COUNTRIES_B")
    public class Country extends AbstractPersistable {
    private static final long serialVersionUID = 1L;
    @Column(name = "CODE", nullable = false)
    private String code;
    @Convert(value = "requiredIndicatorYNConverter")
    @Column(name = "IND_DEFAULT", nullable = false)
    private Boolean defaultCountry;
    @Column(name = "CREATED_BY", nullable = false)
    private Long createdBy;
    @Column(name = "CREATION_DATE", nullable = false)
    private Timestamp creationDate;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "REL_COUNTRY_S1")
    @SequenceGenerator(name = "REL_COUNTRY_S1", sequenceName = "REL_COUNTRY_S1", allocationSize = 1)
    @Column(name = "ID", nullable = false)
    private Long id;
    @Convert("requiredIndicatorYNConverter")
    @Column(name = "IND_ACTIVE", nullable = false)
    private Boolean active;
    @Convert("requiredIndicatorYNConverter")
    @Column(name = "IND_UPPER_ADDITIONAL_PART_1", nullable = false)
    private Boolean upperAdditionalPart1;
    @Column(name = "IND_UPPER_ADDITIONAL_PART_2", nullable = false)
    @Convert("requiredIndicatorYNConverter")
    private Boolean upperAdditionalPart2;
    @Convert("requiredIndicatorYNConverter")
    @Column(name = "IND_UPPER_ADDITIONAL_PART_3", nullable = false)
    private Boolean upperAdditionalPart3;
    @Convert("requiredIndicatorYNConverter")
    @Column(name = "IND_UPPER_CITY", nullable = false)
    private Boolean upperCity;
    @Convert("requiredIndicatorYNConverter")
    @Column(name = "IND_UPPER_NR_ADDITION", nullable = false)
    private Boolean upperNrAddition;
    @Convert("requiredIndicatorYNConverter")
    @Column(name = "IND_UPPER_REGION", nullable = false)
    private Boolean upperRegion;
    @Column(name = "IND_UPPER_STREET", nullable = false)
    @Convert("requiredIndicatorYNConverter")
    private Boolean upperStreet;
    @Column(name = "PROMPT_ADDITIONAL_PART_1")
    private String promptAdditionalPart1;
    @Column(name = "PROMPT_ADDITIONAL_PART_2")
    private String promptAdditionalPart2;
    @Column(name = "PROMPT_ADDITIONAL_PART_3")
    private String promptAdditionalPart3;
    @Column(name = "LAST_UPDATED_BY", nullable = false)
    private Long lastUpdatedBy;
    @Column(name = "LAST_UPDATED_DATE", nullable = false)
    private Timestamp lastUpdatedDate;
    @Column(name = "REFERENCE_CODE")
    private String referenceCode;
    @Version
    @Column(name = "OBJECT_VERSION_NUMBER", nullable = false)
    private Long objectVersionNumber;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "country")
    private List<CountryTl> countryTlList;
    @OneToMany(mappedBy = "country")
    private List<CountryRegion> countryRegionList;
    @ManyToOne
    @JoinColumn(name = "TRANSACTION_SOURCE_ID", referencedColumnName = "ID")
    private TransactionSource transactionSource;
    @ManyToOne
    @JoinColumn(name = "CULO_ID_CONDITION", referencedColumnName = "ID", nullable = true)
    private CustomLogic conditionCustomLogic;
    @ManyToOne
    @JoinColumn(name = "CULO_ID_FUNCTION", referencedColumnName = "ID", nullable = true)
    private CustomLogic functionCustomLogic;
    @OneToMany(mappedBy = "country")
    private List<BankAccountValidation> bankAccountValidationList;
    public Country() {
    public String getCode() {
    return code;
    public void setCode(String code) {
    this.code = code.toUpperCase();
    public Long getCreatedBy() {
    return createdBy;
    public void setCreatedBy(Long createdBy) {
    this.createdBy = createdBy;
    public Timestamp getCreationDate() {
    return creationDate;
    public void setCreationDate(Timestamp creationDate) {
    this.creationDate = creationDate;
    @Override
    public Long getId() {
    return id;
    public void setId(Long id) {
    this.id = id;
    public Long getLastUpdatedBy() {
    return lastUpdatedBy;
    public void setLastUpdatedBy(Long lastUpdatedBy) {
    this.lastUpdatedBy = lastUpdatedBy;
    public Timestamp getLastUpdatedDate() {
    return lastUpdatedDate;
    public void setLastUpdatedDate(Timestamp lastUpdatedDate) {
    this.lastUpdatedDate = lastUpdatedDate;
    public Long getObjectVersionNumber() {
    return objectVersionNumber;
    public void setObjectVersionNumber(Long objectVersionNumber) {
    this.objectVersionNumber = objectVersionNumber;
    public List<CountryTl> getCountryTlList() {
    return countryTlList;
    public void setCountryTlList(List<CountryTl> countryTlList) {
    this.countryTlList = countryTlList;
    public CountryTl addCountryTl(CountryTl countryTl) {
    getCountryTlList().add(countryTl);
    countryTl.setCountry(this);
    return countryTl;
    public CountryTl removeCountryTl(CountryTl countryTl) {
    getCountryTlList().remove(countryTl);
    countryTl.setCountry(null);
    return countryTl;
    public List<CountryRegion> getCountryRegionList() {
    return countryRegionList;
    public void setCountryRegionList(List<CountryRegion> countryRegionList) {
    this.countryRegionList = countryRegionList;
    public CountryRegion addRegion(CountryRegion countryRegion) {
    getCountryRegionList().add(countryRegion);
    countryRegion.setCountry(this);
    return countryRegion;
    public CountryRegion removeRegion(CountryRegion countryRegion) {
    getCountryRegionList().remove(countryRegion);
    countryRegion.setCountry(null);
    return countryRegion;
    public TransactionSource getTransactionSource() {
    return transactionSource;
    public void setTransactionSource(TransactionSource transactionSource) {
    this.transactionSource = transactionSource;
    public void setActive(Boolean active) {
    this.active = active;
    public Boolean isActive() {
    return active;
    public void setUpperAdditionalPart1(Boolean upperAdditionalPart1) {
    this.upperAdditionalPart1 = upperAdditionalPart1;
    public Boolean isUpperAdditionalPart1() {
    return upperAdditionalPart1;
    public void setUpperAdditionalPart2(Boolean upperAdditionalPart2) {
    this.upperAdditionalPart2 = upperAdditionalPart2;
    public Boolean isUpperAdditionalPart2() {
    return upperAdditionalPart2;
    public void setUpperAdditionalPart3(Boolean upperAdditionalPart3) {
    this.upperAdditionalPart3 = upperAdditionalPart3;
    public Boolean isUpperAdditionalPart3() {
    return upperAdditionalPart3;
    public void setUpperCity(Boolean upperCity) {
    this.upperCity = upperCity;
    public Boolean isUpperCity() {
    return upperCity;
    public void setUpperNrAddition(Boolean upperNrAddition) {
    this.upperNrAddition = upperNrAddition;
    public Boolean isUpperNrAddition() {
    return upperNrAddition;
    public void setUpperRegion(Boolean upperRegion) {
    this.upperRegion = upperRegion;
    public Boolean isUpperRegion() {
    return upperRegion;
    public void setUpperStreet(Boolean upperStreet) {
    this.upperStreet = upperStreet;
    public Boolean isUpperStreet() {
    return upperStreet;
    public String getName() {
    return ((CountryTl) getLocaleBasedTL()).getName();
    public void setName(String name) {
    ((CountryTl) getLocaleBasedTL()).setName(name);
    updateAttributeForOtherLocales(this, "name", name);
    public void setDefaultCountry(Boolean defaultCountry) {
    this.defaultCountry = defaultCountry;
    public Boolean isDefaultCountry() {
    return defaultCountry;
    public void setPromptAdditionalPart1(String promptAdditionalPart1) {
    this.promptAdditionalPart1 = promptAdditionalPart1;
    public String getPromptAdditionalPart1() {
    return promptAdditionalPart1;
    public void setPromptAdditionalPart2(String promptAdditionalPart2) {
    this.promptAdditionalPart2 = promptAdditionalPart2;
    public String getPromptAdditionalPart2() {
    return promptAdditionalPart2;
    public void setPromptAdditionalPart3(String promptAdditionalPart3) {
    this.promptAdditionalPart3 = promptAdditionalPart3;
    public String getPromptAdditionalPart3() {
    return promptAdditionalPart3;
    public void setBankAccountValidationList(
    List<BankAccountValidation> bankAccountValidationList) {
    this.bankAccountValidationList = bankAccountValidationList;
    public List<BankAccountValidation> getBankAccountValidationList() {
    return bankAccountValidationList;
    public BankAccountValidation addBankAccountValidation(
    BankAccountValidation bankAccountValidation) {
    this.getBankAccountValidationList().add(bankAccountValidation);
    bankAccountValidation.setCountry(this);
    return bankAccountValidation;
    public BankAccountValidation removeBankAccountValidation(
    BankAccountValidation bankAccountValidation) {
    this.getBankAccountValidationList().remove(bankAccountValidation);
    bankAccountValidation.setCountry(null);
    return bankAccountValidation;
    @PrePersist
    public void preInsertActions() {
    MLSHandlerUtil.setUpAuditAttributes(this);
    @PreUpdate
    public void preUpdateActions() {
    MLSHandlerUtil.updateAuditAttributes(this);
    public void setConditionCustomLogic(CustomLogic conditionCustomLogic) {
    this.conditionCustomLogic = conditionCustomLogic;
    public CustomLogic getConditionCustomLogic() {
    return conditionCustomLogic;
    public void setFunctionCustomLogic(CustomLogic functionCustomLogic) {
    this.functionCustomLogic = functionCustomLogic;
    public CustomLogic getFunctionCustomLogic() {
    return functionCustomLogic;
    public void setReferenceCode(String referenceCode) {
    this.referenceCode = referenceCode;
    public String getReferenceCode() {
    return referenceCode;
    }

  • Cache problem

    Hi
    We use TopLink for persisting POJOs, and use the MergeClonesWithReferences method for inserting and updating objects.
    Insertion and updating works fine, but an inserted object does not appear in a result if a new session is used to read the object.
    Example: Person has a collection of cards. In the db the card is inserted and the foreign key is set so that it points to the person. I can see the card in the db. If i now use a new session to read the object the new card is not in the cardcollection of the person. I will have to restart my application server for the card to appear in the collection. any ideas for the reason?
    I think it migth be that the person object is not updated in the cache. What is the best approach for ensuring that upon inserts/updates Toplink refreshes/synchronizes its cache?
    Thanks

    The code for obtaining a clientsession (is in a helper class for my DAO objects)
    public static ClientSession getClientSession(String sessionName) {
    Server server = (Server) SessionManager.getManager().getSession(
    sessionName);
    ClientSession session = (ClientSession) server.acquireClientSession();
    return session;
    My sessions.xml file:
    <toplink-configuration>
    <session>
    <name>clerk</name>
    <project-xml>toplink.xml</project-xml>
    <session-type>
    <server-session/>
    </session-type>
    <login>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <connection-url>jdbc:oracle:thin:@xxx.xxx.xxx.xx:1521:SID</connection-url>
    <platform-class>oracle.toplink.oraclespecific.Oracle9Platform</platform-class>
    <uses-native-sequencing>true</uses-native-sequencing>
    <sequence-preallocation-size>1</sequence-preallocation-size>
    <user-name>asdasd</user-name>
    <password>asdasd</password>
    </login>
    </session>
    </toplink-configuration>
    Does this create a new instance of a ServerSession? In that case should I have a static ServerSession for my DAOHelper class?
    The objects are inserted using uow.mergeCloneWithReferences(). After insertion I return a copy of the cached object by using the following code:
    public static Object copyObjectWithPK(Object obj, ClientSession sess) {
    if (pkPolicy == null) {
    pkPolicy = new ObjectCopyingPolicy();
    pkPolicy.setShouldResetPrimaryKey(false);
    pkPolicy.cascadeAllParts();
    return sess.copyObject(obj, pkPolicy);
    If I do not do this Toplink will not update objects when I on a later time call uow.mergeClonesWithReferences.
    Since I insert classes using a UnitOfWork the changes should be merged into the shared cache. Perhaps my problem is that I acquire the session in a wrong way??

  • Problem in using Unit of Work with executeNonSelectingCall() method

    Hi,
    I am using external Connection Pooling and Transaction Controller of JBoss in Toplink.
    When I am getting the data from DB and do "clientSession.release();", it works fine.
    I get the clientSession as follows:
    serversession = (Server) SessionManager.getManager().getSession(new XMLSessionConfigLoader(),"Session", Thread.currentThread().getContextClassLoader(), false, true);
    serversession.login();
    ClientSession clientsession = serversession.acquireClientSession();
    I am facing the problems in two cases:
    Case 1: But when I get the UOW through "transaction = clientSession.getActiveUnitOfWork();" and insert the data, commit and do "clientSession.release();", I get the following error:
    [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@c42091
    I removed clientSession.release(); from my finally{} block still I am getting the same error.
    Case 2: But when I get the UOW through "transaction = clientSession.acquireUnitOfWork();" and insert the data, commit and do "clientSession.release();", I get the following error:
    17:48:55,670 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract java.lang.String com.pearson.pix.business.purchaseorder.interfaces.PurchaseOrderLocal.saveOrderConfirmation(com.pearson.pix.dto.purchaseorder.POHeader) throws com.pearson.pix.exception.AppException, causedBy:
    org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=asad/139, BranchQual=, localId=139] status=STATUS_NO_TRANSACTION; - nested throwable: (java.lang.NullPointerException)
         at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:354)
    I am not able to understand what to do. Pls. help.
    Thanks

    Locking a row that does not exist can be difficult.
    On most database you can lock an entire table through "LOCK TABLE <table>", however this may be extreme. Potentially you could also insert an empty row into the table with the id that you want to lock, then you would have a write lock on the row until you commit the transaction.

  • Problem in inserting a node in Treeview.

    Hi all,
    I'm having a problem in inserting a node in the
    treeview always it appends in the end of the
    sibling.
    Basically on double clicking of any node in the
    treeview should create a copy of the double clicked
    node and just insert the copy of the doubleclicked
    node next to the doubleclicked node instead at the end of the sibling.
    if i do this it will to the end of all the siblings.
    copyObject = l_SelectedNode.Clone();
    copyObject.Parent = l_SelectedNode.Parent;
    instead of next to it.
    I am trying something like this:
    RootNode
    |
    ---CHILD Sibling Node1
    | |
    ----GrandChild1Sibling1
    | |
    ---GrandChild1Sibling2 <<-- double clicking
    (GrandChild1Sibling2)
    | |
    <<-- it must add
    (GrandChild1Sibling2_copy)
    ---GrandChild1Sibling3
    | |
    ---GrandChild1Sibling4
    | << -- But it is adding a copy here
    at the end of all sibbling..
    |
    ---CHILD Sibling Node2
    | |
    -------GrandChild2Sibling1
    | |
    ------GrandChild2Sibling2
    | |
    ------GrandChild2Sibling3
    | |
    ------GrandChild2Sibling4
    |
    i am doing GrandChild1Sibling2_copy.parent =
    GrandChild1Sibling2.Parent;
    it will always add in the end of all the sibling as
    (GrandChild1Sibling5_copy) instead of next to
    (GrandChild1Sibling3_copy) Just below the GrandChild1Sibling2.
    Is there any simple soln or any ordering factor which i should look for.
    Thanx in advance...
    Regards,
    -Prasad

    Hello,
    Check the following link.
    SQL error 1653
    Hope it helps in solving your problem.
    Thanks and Regards,
    Sachin

  • DeepMergeClone problem with unsolicited updates

    Hi,
    I am having an odd problem with deepMergeClone and was hoping someone could point me in the correct direction. I am using Weblogic, WebLogicJTSExternalTransactionController, and TopLink 4.6.
    My object model is something like:
    Organization
    - Address
    - Employees(collection of Person)
    - Name, etc...
    Person
    - Address
    - Name, etc...
    Address
    - Region
    - Country
    - Street1, etc...
    The application uses Session Beans that provide TopLink mapped objects to a Servlet layer using Struts. The objects are updated, created, etc. in the Struts actions and then sent to the Session Beans. In the Session Bean we do the something like
    ExternalTransactionController controller = session.getExternalTransactionController();
    UnitOfWork uow = uow = controller.getActiveUnitOfWork();
    uow.readObject(obj); //ensure obj is cached and registered
    uow.deepMergeClone(obj);
    Here is my problem: In the Struts layer, I read a organization by id for an update.
    Updating an organization.address.region will sometimes cause an update to multiple employee's address.region. If you look at the object heirarchy before it gets passed into deepMergeClone, everything looks great.
    If I add code to read the address by id for the organization.address and then set the address into the organization, the update seems to work as expected.
    Is there some rule about needing to register nested objects prior to deepMergeClone? Any other thoughts on what I might be doing wrong?
    Tom

    DeepMergeClone is a very useful feature of TopLink as it allows the application to not have to be concerned with what it changes on the client. The client can traverse any relationships of the objects that are serialized to it (provided the relationships were serialized) and make whatever changes to whatever objects it desires. It can then send the entire object graph back to the server which can does not have to be aware of what the client was doing and can just deepMergeClone everything back into a unit of work and commit the changes to the database.
    Unfortunately the main benefit of deepMergeClone can also be its biggest issue when something goes wrong. DeepMergeClone traverses "everything" related to an object and merges "everything", for complex objects this can occasionally lead to the merging of changes that were not intended or desired by the client.
    Examples can include:
    - Transient attributes. These will be serialized as null so will be merged as null into the unit of work causing incorrect updates to null.
    - Duplicate objects and loss of object identity. Since TopLink is not running on the client, it is possible for the client to violate object identity through retrieving two separately serialized objects from the server that contain relationships to the same object. If these two objects are then related and serialized back to the server and deepMergeClone'd, TopLink will be given two different versions of the same object, this object can be merged twice and one copy can overwrite the other copy. This may be what is occurring with the problem at the start of this thread.
    There is another thread with a similar issue that also links to another thread that has a good description of each of the unit of work merge APIs.
    Re: 1-M deepMergeClone leaves old items in DB
    In general deepMergeClone is a very useful feature, and if you are using it successfully definitely don't stop using it. But if you commonly experience problems, or performance issues, you may wish the consider one of the other merge APIs that give the application more control over what is and is not merged.
    If you are still experiencing the problem and have verified that you are not violating object identity, you will probably need to contact technical support to have them investigate your issue in more detail.

  • JNDI lookup problem in WAS 5.1

    Hello all,
    I have generated an EAR using XDoclet and MyEclipse. When I deploy this EAR on WAS 5.1, I get the following exception:
    javax.naming.NameNotFoundException: Context: WarHog/nodes/WarHog/servers/server1, name: ejb/TEDIObjectManagerLocal: First component in name TEDIObjectManagerLocal not found.  Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
         at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:85)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
         at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
         at com.ibm.rmi.iiop.CDRInputStream.readBoxedIDLEntity(CDRInputStream.java:2112)
         at com.ibm.rmi.iiop.CDRInputStream.readIDLValue(CDRInputStream.java:2177)
         at com.ibm.rmi.iiop.CDRInputStream.fast_read_value(CDRInputStream.java:1734)
         at com.ibm.rmi.io.IIOPInputStream.readValueType(IIOPInputStream.java:2085)
         at com.ibm.rmi.io.IIOPInputStream.readObjectField(IIOPInputStream.java:2057)
         at com.ibm.rmi.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:1765)
         at com.ibm.rmi.io.IIOPInputStream.inputObjectUsingClassDesc(IIOPInputStream.java:1348)
         at com.ibm.rmi.io.IIOPInputStream.continueSimpleReadObject(IIOPInputStream.java:420)
         at com.ibm.rmi.io.IIOPInputStream.simpleReadObjectLoop(IIOPInputStream.java:404)
         at com.ibm.rmi.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:347)
         at com.ibm.rmi.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:200)
         at com.ibm.rmi.iiop.CDRInputStream.read_value(CDRInputStream.java:1367)
         at com.ibm.rmi.util.ProxyUtil.copyObject(ProxyUtil.java:450)
         at com.ibm.CORBA.iiop.UtilDelegateImpl.copyObject(UtilDelegateImpl.java:789)
         at javax.rmi.CORBA.Util.copyObject(Util.java:333)
         at com.wdc.tedi.interfaces._TransformationEngine_Stub.transform(_TransformationEngine_Stub.java:268)
         at com.wdc.tedi.web.TestHarnessBean.translate(TestHarnessBean.java:42)
         at com.wdc.tedi.web.TestHarnessBean.setDataBlob(TestHarnessBean.java:80)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)First of all, I don't really understand what the error means. Is it that the JNDI lookup failed when one of my beans tried to do a lookup on 'ejb/TEDIObjectManagerLocal'? I believe there's some configuration that went wrong (EJB reference binding or something) when I deployed the EAR. The reason I don't think it's a faulty code is because the EAR runs like a charm when I deploy it on Oracle 10g and Weblogic.
    I am really stuck on this problem and shall appreciate any help that I can get. I can send the code, xdoclet tags and configuration if that might assist someone.
    Thanks
    -ybh6336

    Hello all,
    I'm still stuck on this issue. Following are the entries related to my
    application when I do a 'dumpNameSpace':
       28 (top)/nodes/WarHog/servers/server1/ejb/tedi/TEDIObjectManager
       28
    com.wdc.tedi.interfaces._TEDIObjectManagerHome_Stub
       29 (top)/nodes/WarHog/servers/server1/ejb/tedi/DSValueLookup
       29
    com.wdc.tedi.interfaces._DSValueLookupHome_Stub
       30 (top)/nodes/WarHog/servers/server1/ejb/tedi/TransformationEngine
       30
    com.wdc.tedi.interfaces._TransformationEngineHome_StubObservations:
    - I only see the namespace entries for my Session beans. There's one
    entity bean also which does not show up.
    - I don't see anything for the Local Home interfaces, it shows only the
    Home interfaces.
    As additional information, I'm looking up 'TEDIObjectManagerLocal'
    using 'ejb/TEDIObjectManagerLocal'. I also tried using 'local:ejb/ejb/TEDIObjectManagerLocal' (as Karthyk suggested) and
    'java:comp/env/ejb/TEDIObjectManagerLocal', but that does not work
    either.
    Also, the XDoclet tags that I use to generate the interfaces for
    TEDIObjectManager bean are as follows:
    /* @ejb.bean name="TEDIObjectManager"
    *           display-name="TEDIObjectManager"
    *           description="TEDIObjectManager"
    *           jndi-name="ejb/tedi/TEDIObjectManager"
    *           local-jndi-name="ejb/TEDIObjectManagerLocal"
    *           type="Stateless"
    *           view-type="both"
    * @ejb.util generate="physical"
    * @ejb.ejb-ref ejb-name="TEDIObject"
    * view-type = "local"
    * ref-name = "ejb/TEDIObjectLocal"
    * @oc4j.bean jndi-name="ejb/tedi/TEDIObjectManager"
    */My ejb-jar.xml looks like following for that bean:
    <session >
             <description><![CDATA[TEDIObjectManager]]></description>
             <display-name>TEDIObjectManager</display-name>
             <ejb-name>TEDIObjectManager</ejb-name>
             <home>com.wdc.tedi.interfaces.TEDIObjectManagerHome</home>
             <remote>com.wdc.tedi.interfaces.TEDIObjectManager</remote>
    <local-home>com.wdc.tedi.interfaces.TEDIObjectManagerLocalHome</local-home>
             <local>com.wdc.tedi.interfaces.TEDIObjectManagerLocal</local>
    <ejb-class>com.wdc.tedi.ejb.TEDIObjectManagerSession</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
             <ejb-local-ref >
                <ejb-ref-name>ejb/TEDIObjectLocal</ejb-ref-name>
                <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>com.wdc.tedi.interfaces.TEDIObjectLocalHome</local-home>
                <local>com.wdc.tedi.interfaces.TEDIObjectLocal</local>
                <ejb-link>TEDIObject</ejb-link>
             </ejb-local-ref>
          </session>AND following for the bean that is referencing it:
    <session >
             <description><![CDATA[TransformationEngine]]></description>
             <display-name>TransformationEngine</display-name>
             <ejb-name>TransformationEngine</ejb-name>
             <home>com.wdc.tedi.interfaces.TransformationEngineHome</home>
             <remote>com.wdc.tedi.interfaces.TransformationEngine</remote>
    <local-home>com.wdc.tedi.interfaces.TransformationEngineLocalHome</local-home>
    <local>com.wdc.tedi.interfaces.TransformationEngineLocal</local>
    <ejb-class>com.wdc.tedi.ejb.TransformationEngineSession</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
             <ejb-local-ref >
                <ejb-ref-name>ejb/TEDIObjectManagerLocal</ejb-ref-name>
                <ejb-ref-type>Session</ejb-ref-type>
    <local-home>com.wdc.tedi.interfaces.TEDIObjectManagerLocalHome</local-home>
    <local>com.wdc.tedi.interfaces.TEDIObjectManagerLocal</local>
                <ejb-link>TEDIObjectManager</ejb-link>
             </ejb-local-ref>
          </session>The entries in ibm-ejb-jar-bnd.xmi (generated using MyEclipse) are as
    follows for the two beans:
    <ejbBindings
             xmi:id="Session_bnd_1"
             jndiName="ejb/tedi/TransformationEngine">
             <ejbRefBindings xmi:id="EJBRefBnd_1"
    jndiName="ejb/TEDIObjectManagerLocal">
        <bindingEjbRef href="META-INF/ejb-jar.xml#EJBLocalRef_1"/>
             </ejbRefBindings>
             <enterpriseBean
                xmi:type="ejb:Session"
    href="META-INF/ejb-jar.xml#Session_TransformationEngine" />
          </ejbBindings>
    <ejbBindings
             xmi:id="Session_bnd_3"
             jndiName="ejb/tedi/TEDIObjectManager">
             <ejbRefBindings xmi:id="EJBRefBnd_2"
    jndiName="ejb/TEDIObjectLocal">
        <bindingEjbRef href="META-INF/ejb-jar.xml#EJBLocalRef_2"/>
             </ejbRefBindings>
             <enterpriseBean
                xmi:type="ejb:Session"
    href="META-INF/ejb-jar.xml#Session_TEDIObjectManager" />
          </ejbBindings>I know I'm swamping the post with code, but please let me know if anyone finds something unusual.
    NOTE: When deploying on WAS, in the 'Map EJB references to beans' step, I'm giving the following values for 'TransformationEngine' bean:
    Reference binding: ejb/TEDIObjectManagerLocal
    JNDI Name: ejb/tedi/TEDIObjectManager
    There's one other similar binding that works for 'TEDIObjectManager'
    bean:
    Reference binding: ejb/TEDIObjectLocal
    JNDI Name: ejb/TEDIObject
    Everything in ejb-jar and ibm-ejb-jar-bnd.xmi look similar for this working bean, there is one difference though, I do the lookup on this one using 'java:comp/env/ejb/TEDIObjectLocal', but I've already tried that for the other one.
    Really appreciate your time.
    Thanks
    -yogesh

  • Out of memory while commiting uow objects

    we are getting this error message when we try to persist our objects, is there an upper limit on the object size that we can persist? Do we need to enable or
    disable any property? we currently have OptimizeDataConversion turned off
    com.integral.finance.dealing.ejb.RequestService.process(com.integral.message.WorkflowMessage)
    throws java.rmi.RemoteException
    java.lang.OutOfMemoryError: allocLargeObjectOrArray - Object size: 1328752, Num
    elements: 664365
    at
    oracle.jdbc.driver.OraclePreparedStatement.allocBinds(OraclePreparedStatement.java:1147)
    at
    oracle.jdbc.driver.OraclePreparedStatement.growBinds(OraclePreparedStatement.java:1294)
    at
    oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1920)
    at
    oracle.jdbc.driver.OraclePreparedStatement.addBatch(OraclePreparedStatement.java:8930)
    at
    oracle.toplink.internal.databaseaccess.DatabasePlatform.addBatch(DatabasePlatform.java:138)
    at
    oracle.toplink.platform.database.oracle.Oracle9Platform.addBatch(Oracle9Platform.java:207)
    at
    oracle.toplink.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.prepareBatchStatements(ParameterizedSQLBatchWritingMechanism.java:170)
    at
    oracle.toplink.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:124)
    at
    oracle.toplink.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.appendCall(ParameterizedSQLBatchWritingMechanism.java:71)
    at
    oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:478)
    at
    oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:441)
    at oracle.toplink.publicinterface.Session.executeCall(Session.java:728)
    at
    oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:117)
    at
    oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:103)
    at
    oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.insertObject(DatasourceCallQueryMechanism.java:238)
    at
    oracle.toplink.internal.queryframework.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:158)
    at
    oracle.toplink.internal.queryframework.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:173)
    at
    oracle.toplink.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:429)
    at
    oracle.toplink.queryframework.InsertObjectQuery.executeCommit(InsertObjectQuery.java:63)
    at
    oracle.toplink.queryframework.InsertObjectQuery.executeCommitWithChangeSet(InsertObjectQuery.java:76)
    at
    oracle.toplink.internal.queryframework.DatabaseQueryMechanism.performUserDefinedWrite(DatabaseQueryMechanism.java:522)
    at
    oracle.toplink.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:358)
    at
    oracle.toplink.queryframework.WriteObjectQuery.executeCommitWithChangeSet(WriteObjectQuery.java:107)
    at
    oracle.toplink.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:254)
    at
    oracle.toplink.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:47)
    at
    oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:620)
    at
    oracle.toplink.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:542)
    at
    oracle.toplink.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:100)
    at
    oracle.toplink.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:72)
    at
    oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2631)
    at
    oracle.toplink.publicinterface.Session.executeQuery(Session.java:993)
    at
    oracle.toplink.publicinterface.Session.executeQuery(Session.java:950)
    at
    oracle.toplink.mappings.ObjectReferenceMapping.preInsert(ObjectReferenceMapping.java:469)
    at
    oracle.toplink.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:380)
    at
    oracle.toplink.queryframework.InsertObjectQuery.executeCommit(InsertObjectQuery.java:65)
    at
    oracle.toplink.queryframework.InsertObjectQuery.executeCommitWithChangeSet(InsertObjectQuery.java:76)
    at
    oracle.toplink.internal.queryframework.DatabaseQueryMechanism.performUserDefinedWrite(DatabaseQueryMechanism.java:522)
    at
    oracle.toplink.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:358)
    at
    oracle.toplink.queryframework.WriteObjectQuery.executeCommitWithChangeSet(WriteObjectQuery.java:110)
    at
    oracle.toplink.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:254)
    at
    oracle.toplink.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:47)
    at
    oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:620)
    at
    oracle.toplink.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:542)
    at
    oracle.toplink.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:100)
    at
    oracle.toplink.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:72)
    at
    oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2631)
    at
    oracle.toplink.publicinterface.Session.executeQuery(Session.java:993)
    at
    oracle.toplink.publicinterface.Session.executeQuery(Session.java:950)
    at
    oracle.toplink.mappings.ObjectReferenceMapping.preInsert(ObjectReferenceMapping.java:469)
    at
    oracle.toplink.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:380)
    at
    oracle.toplink.queryframework.InsertObjectQuery.executeCommit(InsertObjectQuery.java:65)
    at
    oracle.toplink.queryframework.InsertObjectQuery.executeCommitWithChangeSet(InsertObjectQuery.java:76)
    at
    oracle.toplink.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:254)
    at
    oracle.toplink.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:47)
    at
    oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:620)
    at
    oracle.toplink.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:542)
    at
    oracle.toplink.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:100)
    at
    oracle.toplink.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:72)
    at
    oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2631)
    at
    oracle.toplink.publicinterface.Session.executeQuery(Session.java:993)
    at
    oracle.toplink.publicinterface.Session.executeQuery(Session.java:950)
    at
    oracle.toplink.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:243)
    at
    oracle.toplink.internal.sessions.CommitManager.commitAllObjectsForClassWithChangeSet(CommitManager.java:219)
    at
    oracle.toplink.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:174)
    at
    oracle.toplink.publicinterface.Session.writeAllObjectsWithChangeSet(Session.java:3195)
    at
    oracle.toplink.publicinterface.UnitOfWork.commitToDatabase(UnitOfWork.java:1320)
    at
    oracle.toplink.publicinterface.UnitOfWork.commitToDatabaseWithChangeSet(UnitOfWork.java:1416)
    at
    oracle.toplink.publicinterface.UnitOfWork.commitRootUnitOfWork(UnitOfWork.java:1164)
    at
    oracle.toplink.publicinterface.UnitOfWork.commit(UnitOfWork.java:932)

    Hello, we encounter this problem for years on TopLink then there is not in Hibernate.
    The problem is that Toplink awaits the uow.commit () before merging changes in the cache objects and before release work objects (backup and clone).
    If a transaction modify 10.000 objects, TopLink references 30.000 objects (10.000 refCache, 10.000 clone, 10.000 backup). The 30.000 objects will be released once the database commit completed and the merge completed in memory.
    We want Toplink offers an option to make several Flush in unitOfWork, each flush will send SQL to database (insert, update, delete) without sql commit then mark flushed Objects as invalid before releasing them so that the garbage collector can garbage flushed objects.
    Example:
    {color:#0000ff}*uow.begin()* {color} / * begin of transaction on 10.000 objects * /
    application modify first 1.000 objects (from 1 to 1.000)
    uow.flush () / * Toplink send sql to database, toplink flag 1.000 as invalid, Toplink release 1.000 objects to the GC * /
    application modify next 1000 objects (from 1.001 to 2.000)
    uow.flush () / * Toplink send sql to database, toplink flag 1.000 as invalid, Toplink release 1.000 objects to the GC * /
    application modify last 1000 objects objects (9001 .. 10000)
    uow.flush () / * Toplink send sql to database, toplink flag 1.000 as invalid, Toplink release 1.000 objects to the GC * /
    {color:#0000ff}*uow.commit();* {color}/ * Toplink send sql-commit to database, no objects to release to GC* /
    Can you tell me if you intend to implement this function because we need long running transaction process without outOfMemory suffer?
    Thank you for your understanding
    Tabi

  • Problem controlling the order of deletes

    Hello,
    I built a very simple example that uses two Java classes (Department and Employee) with a one-to-many relationship. The property "name" of class Employee maps to the primary key column of the EMPLOYEE table in the database. Now if I remove all employees from a department and then insert one employee who happens to have the same name as one of ex-employees, the things go wrong:
    [TopLink Info]: DatabaseSession(101)--acquire unit of work: 216
    [TopLink Info]: DatabaseSession(101)--Connection(102)--SELECT NAME FROM MACIEJ.DEPARTMENT WHERE (NAME = 'IT')
    [TopLink Info]: UnitOfWork(216)--begin unit of work commit
    [TopLink Info]: DatabaseSession(101)--Connection(102)--begin transaction
    [TopLink Info]: UnitOfWork(216)--Connection(102)--INSERT INTO MACIEJ.EMPLOYEE (NAME, FIRST_NAME, DEPARTMENT_NAME) VALUES ('Schinzel', 'Dieter', 'IT')
    [TopLink Info]: UnitOfWork(216)--Connection(102)--DELETE FROM MACIEJ.EMPLOYEE WHERE (NAME = 'Marczukajtis')
    [TopLink Info]: UnitOfWork(216)--Connection(102)--DELETE FROM MACIEJ.EMPLOYEE WHERE (NAME = 'Schinzel')
    [TopLink Info]: DatabaseSession(101)--Connection(102)--commit transaction
    [TopLink Info]: UnitOfWork(216)--end unit of work commit
    [TopLink Info]: UnitOfWork(216)--release unit of work
    This happens also when I am using the method setShouldPerformDeletesFirst(true). The deletes are still executed after the insert. The code follows.
    ExpressionBuilder builder = new ExpressionBuilder(Department.class);
    Expression constraint = builder.get("name").equal("IT");
    UnitOfWork uow = this.session.acquireUnitOfWork();
    uow.setShouldPerformDeletesFirst(true);
    Department dep = (Department) uow.readAllObjects(Department.class, constraint).get(0);
    uow.logMessages();
    dep.removeAllEmployees();
    // Employee emp = new Employee();
    Employee emp = (Employee) uow.registerObject(new Employee());
    emp.setName("Schinzel");
    emp.setFirstName("Dieter");
    dep.addEmployee(emp);
    uow.commit();
    Another problem I encountered is that I have to use registerObject() on the new Employee (still if the value of "name" is identical to one of the employee's names that I am removing), because otherwise I am getting this:
    Local Exception Stack:
    Exception [TOPLINK-6004] (OracleAS TopLink - 10g (9.0.4) (Build 031126)): oracle.toplink.exceptions.QueryException
    Exception Description: The object [cern.toplink.try1.Employee@ec[ name: Schinzel ; 1st name: Dieter ; dep: IT ]], of class [class cern.toplink.try1.Employee], with identity hashcode (System.identityHashCode()) [236],
    is not from this UnitOfWork object space, but the parent session's. The object was never registered in this UnitOfWork,
    but read from the parent session and related to an object registered in the UnitOfWork. Ensure that you are correctly
    registering your objects. If you are still having problems, you can use the UnitOfWork.validateObjectSpace() method to
    help debug where the error occurred. For more information, see the manual or FAQ.
    I would appreciate any hints how I can force the deletes to happen before the insert.
    Cheers,
    Maciej

    You cannot have two different objects in the same unit of work with different primary keys.
    You must either update the object instead of deleting and inserting it, or split the operation across two units of work.
    The setShouldPerformDeletesFirst only applies to publicly deleted objects, not objects that are deleted through private owned relationships. If you did not mark the relationship as private-owned and deleted the objects through uow.deleteObject then the deletes would be processed first. However you should still try to avoid having two different objects with the same primary key in the same unit of work.

  • Problem updating a date field via UnitOfWork - TopLink 9.0.3

    Hello,
    we want to change an exisiting application that employs TopLink 9.0.3, Build 423.
    The data is stored in an Oracle 9.2.0.6.
    The specific table has a composite primary key consisting of four fields.
    I can easily create a new Object (foo)
    uow.registerNewObject(foo)
    uow.commit()
    and see the results in the database.
    If I obtain an exising Object (bar) and change an integer
    bar = (Bar) Session.readObject(Bar.class, expr);
    cloneBar = (Bar) uow.registerObject(bar);
    cloneBar.setSomething(42);
    uow.commit()
    everything is fine.
    But if I dare to change a Date field
    cloneBar.setSomethingElse(cal.getTime());
    then
    uow.hasChanges()
    returns true
    but the update does not happen. It is neither logged nor is the data changed in the database.
    Is this a known bug?
    What have I done wrong?
    How can I avoid using hard-coded SQL to update my Bar object?
    Bye,
    Stephan

    Hello,
    it is very disturbing, but I finally found the reason for this problem.
    After decompiling the Project class file (we have no source code of this third-party library), I saw that the mapping for this specific field is set to "readOnly".
    I did not know that TopLink is able to have specific fields "readOnly" and others "readWrite", but it can handle this!
    So it seems that the behaviour is not a bug but a feature :-(
    We can change the mapping before creating the session, with the result that the field is updatable.
    Have a nice day.

  • Updating a persons name using toplink uow

    Hi,
    I am having problems updating the name of a PERSON. I am using Toplink with a SessionBeanFacade.
    I am using a Backing Bean, which is calling the Session Bean Facade. I was debugging the code and the strange thing is: I can see the updated name in the entity and in the uow, but after uow.commit the updated name isn't in the database. Why won't the values from the uow persist?
    SESSION BEAN FACADE
      public Object mergeEntity(Object entity) {
        UnitOfWork uow = getSessionFactory().acquireUnitOfWork();
        Object workingCopy = uow.readObject(entity);
        if (workingCopy == null)
          throw new RuntimeException("Could not find entity to update");
        uow.deepMergeClone(entity);
        uow.commit();
        return workingCopy;
    BACKING BEAN
      public void recoverBusinesspartner(ActionEvent actionEvent) {
        DCBindingContainer dcBind = (DCBindingContainer)getBindings();
        DCIteratorBinding iterBind = (DCIteratorBinding)dcBind.get("personIterator");
        iterBind.getCurrentRow().setAttribute("name", "Bodhy");
        dcBind.getOperationBinding("mergeEntity").execute();
      }Thank you
    Bodhy
    Edited by: Bodhy on 30.09.2008 06:02
    P.S. I don't get any errors or some other message in my log. I am using JDeveloper 11g TP3

    Hello,
    Glad you found the problem. As I mentioned in my previous post, you should not be modifying objects from the session cache. When you do any sort of query on a session other than a UnitOfWork, the objects returned exist in the shared session cache. When you register an object, the state of the object is pulled from the session cache and used for a comparison - TopLink will think that is the state the database is in.
    This is why Detach resolves the issue- it makes a copy of the object so that changes to it do not get put into the cached copy.
    I would recommend looking at:
    http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/cachun001.htm
    and
    http://www.oracle.com/technology/products/ias/toplink/technical/unitOfWorkWP.pdf
    to see how caching and the UOW work in TopLink
    Best Regards,
    Chris

  • Toplink session and UnitOfWork synchronization problem

    Dear forum readers,
    I am not sure i fully understand the way how toplink deals with caching. To me it seems, that i got some pretty scary results, which i am not sure how to interpret and to work around them.
    The following code snippet is part of a unit test:
    >>>>>>>>>>>> snip >>>>>>>>>>>>>>>
    1 public void test2() {
    2
    3 UnitOfWork uow = (UnitOfWork) SessionManager.getSessionManager().getSession().getUnitOfWork();
    4 Justitiabele justitiabele = findJustitiabele("findById", Justitiabele.class, new Long(551));
    5 ((JustitiabeleIdentiteit) justitiabele.getJustitiabeleIdentiteiten().iterator().next()).setMeisjesnaam("Kettner10");
    6 Justitiabele tmp = (Justitiabele) uow.registerObject(justitiabele);
    7 ((JustitiabeleIdentiteit) tmp.getJustitiabeleIdentiteiten().iterator().next()).setMeisjesnaam("Kettner10");
    8 uow.commitAndResume();
    9 }
    10
    11 public Justitiabele findJustitiabele(String queryName, Class objectClass, Object param) {
    12      SessionWrapper toplinkSessionWrapper = getSession();
    13      toplinkSessionWrapper.getClientSession().executeQuery(queryName, objectClass, param);
    14 }
    >>>>>>>>>>>>>>>> snip <<<<<<<<<<<<<<<<
    I am querying a particular object (line 4). Then i make some changes to that object (line 5). Cause the object is not registered in the UnitOfWork these changes shouldn't be persisted. So far so good. To achieve persistency i now register the object, and i make the same modifications to the toplink clone, expecting them after the commit to be persisted in the database.
    Contrary to my expectations, the changes were not persisted!!!
    Deleting line 5 (the modifications, before registering the object), leads to the desired result.
    Somehow the queried object seems to be a direct reference to the (client-) session cache. So when registering the object in the UnitOfWork, the (already modified) backupclone is copied from the session cache to the UnitOfWork. If the same changes are done to the working clone,there are no differences between backup- and working clone and no changes are made in the database.
    It gets even better: I tried to query the object again (before line 6) (even with a different UnitOfWork) before modifying it, in order to retrieve the original state of the object, but again i only was able to find the modified object.
    If the queried object indeed is a reference to some cache, i cannot understand, why that cache is not read only!!!
    Am i doing something wrong ?
    Is there a way to work around this problem?
    What are the consequences for transaction handling ? What about Isolation, when clients can see each others changes in a kind of writeable shared session???
    I try to work around that problem by registering every object, that is queried from the database in the UnitOfWork right after it was queried. This seems to me the only solution, though this is contrary to what the toplink developers guide says, namely, that only objects which are modified should be registered, due to performance reasons.
    I would be grateful to any help in understanding and working around this problem.
    Martin
    PS: Here's the log i got by running the test.:
    STDOUT >>>>>>>>>>>>>>>>>>>>>>>>>>>>
    C:\devtools\jdev\905\jdk\bin\javaw.exe -ojvm -classpath C:\ToplinkDemo\ToplinkDomein\classes;C:\ToplinkDemo\ToplinkDomein\classes\META-INF\ToplinkDomein;C:\devtools\jdev\905\toplink\jlib\source.jar;C:\devtools\jdev\905\lib\xmlparserv2.jar;C:\devtools\jdev\905\lib\xmlcomp.jar;C:\devtools\jdev\905\jdbc\lib\classes12.jar;C:\devtools\jdev\905\jdbc\lib\nls_charset12.jar;C:\devtools\jdev\905\toplink\jlib\toplink.jar org.dji.br.bl.domein.TestMain
    ServerSession(91)--Connection(92)--TopLink, version: OracleAS TopLink - 10g (9.0.4) (Build 031126)
    ServerSession(91)--Connection(92)--connecting session: djisession
    ServerSession(91)--Connection(92)--connecting(DatabaseLogin(
         platform=>Oracle9Platform
         user name=> "dji"
         datasource URL=> "jdbc:oracle:thin:@S-ORACLE01:1521:djipoc"
    ServerSession(91)--Connection(92)--Connected: jdbc:oracle:thin:@S-ORACLE01:1521:djipoc
         User: DJI
         Database: Oracle Version: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
         Driver: Oracle JDBC driver Version: 9.0.1.5.0
    ServerSession(91)--Connection(101)--TopLink, version: OracleAS TopLink - 10g (9.0.4) (Build 031126)
    ServerSession(91)--Connection(101)--connecting session: djisession
    ServerSession(91)--Connection(101)--connecting(DatabaseLogin(
         platform=>Oracle9Platform
         user name=> "dji"
         datasource URL=> "jdbc:oracle:thin:@S-ORACLE01:1521:djipoc"
    ServerSession(91)--Connection(101)--Connected: jdbc:oracle:thin:@S-ORACLE01:1521:djipoc
         User: DJI
         Database: Oracle Version: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
         Driver: Oracle JDBC driver Version: 9.0.1.5.0
    ServerSession(91)--Connection(103)--TopLink, version: OracleAS TopLink - 10g (9.0.4) (Build 031126)
    ServerSession(91)--Connection(103)--connecting session: djisession
    ServerSession(91)--Connection(103)--connecting(DatabaseLogin(
         platform=>Oracle9Platform
         user name=> "dji"
         datasource URL=> "jdbc:oracle:thin:@S-ORACLE01:1521:djipoc"
    ServerSession(91)--Connection(103)--Connected: jdbc:oracle:thin:@S-ORACLE01:1521:djipoc
         User: DJI
         Database: Oracle Version: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
         Driver: Oracle JDBC driver Version: 9.0.1.5.0
    ServerSession(91)--Connection(105)--TopLink, version: OracleAS TopLink - 10g (9.0.4) (Build 031126)
    ServerSession(91)--Connection(105)--connecting session: djisession
    ServerSession(91)--Connection(105)--connecting(DatabaseLogin(
         platform=>Oracle9Platform
         user name=> "dji"
         datasource URL=> "jdbc:oracle:thin:@S-ORACLE01:1521:djipoc"
    ServerSession(91)--Connection(105)--Connected: jdbc:oracle:thin:@S-ORACLE01:1521:djipoc
         User: DJI
         Database: Oracle Version: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
         Driver: Oracle JDBC driver Version: 9.0.1.5.0
    ServerSession(91)--Connection(107)--TopLink, version: OracleAS TopLink - 10g (9.0.4) (Build 031126)
    ServerSession(91)--Connection(107)--connecting session: djisession
    ServerSession(91)--Connection(107)--connecting(DatabaseLogin(
         platform=>Oracle9Platform
         user name=> "dji"
         datasource URL=> "jdbc:oracle:thin:@S-ORACLE01:1521:djipoc"
    ServerSession(91)--Connection(107)--Connected: jdbc:oracle:thin:@S-ORACLE01:1521:djipoc
         User: DJI
         Database: Oracle Version: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
         Driver: Oracle JDBC driver Version: 9.0.1.5.0
    ServerSession(91)--Connection(109)--TopLink, version: OracleAS TopLink - 10g (9.0.4) (Build 031126)
    ServerSession(91)--Connection(109)--connecting session: djisession
    ServerSession(91)--Connection(109)--connecting(DatabaseLogin(
         platform=>Oracle9Platform
         user name=> "dji"
         datasource URL=> "jdbc:oracle:thin:@S-ORACLE01:1521:djipoc"
    ServerSession(91)--Connection(109)--Connected: jdbc:oracle:thin:@S-ORACLE01:1521:djipoc
         User: DJI
         Database: Oracle Version: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
         Driver: Oracle JDBC driver Version: 9.0.1.5.0
    ServerSession(91)--Connection(111)--TopLink, version: OracleAS TopLink - 10g (9.0.4) (Build 031126)
    ServerSession(91)--Connection(111)--connecting session: djisession
    ServerSession(91)--Connection(111)--connecting(DatabaseLogin(
         platform=>Oracle9Platform
         user name=> "dji"
         datasource URL=> "jdbc:oracle:thin:@S-ORACLE01:1521:djipoc"
    ServerSession(91)--Connection(111)--Connected: jdbc:oracle:thin:@S-ORACLE01:1521:djipoc
         User: DJI
         Database: Oracle Version: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.4.0 - Production
         Driver: Oracle JDBC driver Version: 9.0.1.5.0
    ServerSession(91)--sequencing connected, state is ForcedToUseWriteAccessor_State
    ServerSession(91)--client acquired
    ClientSession(114)--acquire unit of work: 113
    ClientSession(114)--Execute query ReadObjectQuery(org.dji.br.bl.domein.justitiabele.Justitiabele)
    ServerSession(91)--Connection(101)--SELECT DJI_NUMMER FROM DJI.JUSTITIABELEN WHERE (DJI_NUMMER = 551)
    ServerSession(91)--Execute query ReadAllQuery(org.dji.br.bl.domein.justitiabele.JustitiabeleIdentiteit)
    ServerSession(91)--Connection(92)--SELECT INDICATIE_NONAMER, ACHTERNAAM, BRN_CODE, MEISJESNAAM, ID, ROEPNAAM, GEBOORTEPLAATS_BUITENLAND, TITEL_BUITENLAND, VOORNAAM, VOORLETTERS, JBE_DJI_NUMMER, DATUM_INGANG, DATUM_EINDE FROM DJI.JUSTITIABELEIDENTITEITEN WHERE (JBE_DJI_NUMMER = 551)
    ServerSession(91)--Execute query ReadObjectQuery(org.dji.br.bl.domein.justitiabele.Justitiabele)
    UnitOfWork(113)--Register the object org.dji.br.bl.domein.justitiabele.Justitiabele@82
    UnitOfWork(113)--Register the existing object org.dji.br.bl.domein.justitiabele.JustitiabeleIdentiteit@84
    UnitOfWork(113)--Register the existing object org.dji.br.bl.domein.justitiabele.Justitiabele@82
    UnitOfWork(113)--begin unit of work commit
    ClientSession(114)--Connection(103)--begin transaction
    UnitOfWork(113)--Execute query WriteObjectQuery(org.dji.br.bl.domein.justitiabele.Justitiabele@83)
    UnitOfWork(113)--Execute query WriteObjectQuery(org.dji.br.bl.domein.justitiabele.JustitiabeleIdentiteit@85)
    ClientSession(114)--Connection(103)--commit transaction
    UnitOfWork(113)--end unit of work commit
    UnitOfWork(113)--resume unit of work
    Process exited with exit code 0.

    Mark,
    The object returned from any query on the sessions is the object from the shared cache. Any changes made to this will change the shared cache.
    You must acquire a UnitOfWork and register the cached object into the UnitOfWork in order to get an isolated copy that can be modified within a transactional context (UnitOfWork) without other threads seeing these transient changes. The typical approach is to read through the session and register objects involved in a change prior to modifications.
    The is a UnitOfWork paper available on TopLink technical information page that may be useful to you:
    http://www.oracle.com/technology/products/ias/toplink/technical/index.html
    Doug

  • Exception during MergeClone in Nested UOW

    I have defined an object model with objA -- 1..1 --> objB.
    Then, in the business logic, I try to create objA and objB in nested UOW, psudo code as follows:
    UOWParent = session.acquireUOW();
    UOWinner1 = UOWParent.acquireUOW();
    objB = new ObjectB;
    UOWinner1.mergeCloneWithReference(objB);
    UOWinner1.commit();
    UOWinner2 = UOWParent.acquireUOW();
    objA = new ObjectA;
    objA.B = objB;
    UOWinner2.mergeCloneWithReference(objA);
    UOWinner2.commit();
    UOWParent.commit();
    (OracleAS TopLink - 10g (9.0.4.9) (Build 060118)): oracle.toplink.exceptions.QueryException Exception Description: The object [com.domain.model.ContainerGroup@191f61c], of class [class com.domain.model.ContainerGroup], with identity hashcode (System.identityHashCode()) [26,342,940], is the original to a registered new object. The UnitOfWork clones registered new objects, so you must ensure that an object is registered before it is referenced by another object. If you do not want the new object to be cloned, use the UnitOfWork.registerNewObject(Object) API. If you are still having problems, you can use the UnitOfWork.validateObjectSpace() method to help debug where the error occurred. For more information, see the manual or FAQ. at oracle.toplink.exceptions.QueryException.backupCloneIsOriginalFromSelf(QueryException.java:160) at oracle.toplink.publicinterface.UnitOfWork.getBackupClone(UnitOfWork.java:1549) at oracle.toplink.publicinterface.UnitOfWork.calculateChanges(UnitOfWork.java:438) at oracle.toplink.publicinterface.UnitOfWork.commitToDatabaseWithChangeSet(UnitOfWork.java:1134) at oracle.toplink.publicinterface.UnitOfWork.commitRootUnitOfWork(UnitOfWork.java:955) at oracle.toplink.publicinterface.UnitOfWork.commit(UnitOfWork.java:770) at org.springframework.orm.toplink.TopLinkTransactionManager.doCommit(TopLinkTransactionManager.java:399) ... 38 more
    If I use the returned object from "UOWinner1.mergeCloneWithReference(objB);", and use this object for "objA.B = objB;" instead during the second transaction, the exception disappeared and the records can be updated successfully in DB
    My Question is...
    1) What's meant by the exception"oracle.toplink.exceptions.QueryException.backupCloneIsOriginalFromSelf"?
    2) What is the object returned by mergeClone? is it a Session Cached object, or a working Clone registered with UOWinner1?
    3) Actually, what's going on during mergeClone? Why the exception thrown is a "QueryException"?
    Message was edited by:
    zolobag

    Why are you using mergeCloneWithReferences when you are creating an object, you would probably be interested in running
    uow.registerObject(persistentObj);
    uow.assignSequenceNumbers();
    A merge clone is if you have an object in the database and a new version from the app/gui. mergeClone lets you merge the changes in via toplink. Toplink is matching references and other assorted items to see what the changeset it and then issues the approptiate SQL to correct it. Remember that you must not read an item out of the session cache, modify it and try to merge clone it via UOW since that is not correct.
    From API:
    mergeCloneWithReferences
    PUBLIC: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or another serialization mechanism), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. The object and its private owned parts are merged. This will include references from this clone to independent objects.
    Returns:
    the registered version for the clone being merged.

Maybe you are looking for