persistence@glassfish.java.net

RE: help me with EJB3!

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Thu, 15 Dec 2005 19:35:15 -0500

This is a know issue when the target of a ManyToOne or OneToOne has compound primary key. (GlassFish issue tracker #53). It should be resolved soon.
--Gordon

-----Original Message-----
From: aung zay [mailto:aungzay0_at_gmail.com]
Sent: Thursday, December 15, 2005 6:26 PM
To: persistence_at_glassfish.dev.java.net
Subject: Re: help me with EJB3!


hi,
    I got exception at the following situation. I also want to know if
my code is correct or not.
 
    Employee
    ----------
    id - PK
    branch_id -PK

    @OneToMany( cascade=CascadeType.ALL ,fetch = FetchType.EAGER,
mappedBy="employee")
    public Collection<PhoneNumber> getPhoneNumbers() {
        return phoneNumbers;
    }

    PhoneNumber
    --------------
    number - PK

    @ManyToOne( cascade= {CascadeType.PERSIST, CascadeType.MERGE} )
    @JoinColumns({
       @JoinColumn(name = "employee_id" ,referencedColumnName="id"),
       @JoinColumn(name = "employee_branch_id",referencedColumnName="name")
    })
    public Employee getEmployee() {
        return employee;
    }

And the exceptions were

Exception [TOPLINK-48] (Oracle TopLink Essentials - 10g release 4
(10.1.4.0.0) (Build 051205Dev)):
oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Multiple writable mappings exist for the field
[ORDERCOMPOSITE.CUSTOMER_ID]. Only one may be defined as writable, all
others must be specified read-only.
Mapping: oracle.toplink.essentials.mappings.OneToOneMapping[customer]
Descriptor: RelationalDescriptor(com.jumino.entity.OrderComposite -->
[DatabaseTable(ORDERCOMPOSITE)])
Exception [TOPLINK-48] (Oracle TopLink Essentials - 10g release 4
(10.1.4.0.0) (Build 051205Dev)):
oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: Multiple writable mappings exist for the field
[ORDERCOMPOSITE.CUSTOMER_NAME]. Only one may be defined as writable,
all others must be specified read-only.
Mapping: oracle.toplink.essentials.mappings.OneToOneMapping[customer]
Descriptor: RelationalDescriptor(com.jumino.entity.OrderComposite -->
[DatabaseTable(ORDERCOMPOSITE)])

Thanks
-AZ-

Gordon Yorke wrote:

>Hello Sailaja,
> The solution to this issue is currently in progress. In the meantime the error you are seeing should only occur when there is a composite PK on both sides of the relationship.
> --Gordon
>
>-----Original Message-----
>From: Sailaja Rao [mailto:Sailaja.Rao_at_Sun.COM]
>Sent: Thursday, December 15, 2005 2:39 PM
>To: persistence_at_glassfish.dev.java.net
>Subject: Re: help me with EJB3!
>
>
>Hi,
>
>https://glassfish.dev.java.net/issues/show_bug.cgi?id=53
>
>I have a test with composite Primary keys in relationship (1-1, 1-M,
>M-1 and M-M) and it fails with the following exception
>
>Thread-4848;|[TopLink Severe]: 2005.09.21
>01:11:55.406--ServerSession(3656671)--Thread(Thread[SelectorThread-4848,5,main])--Local
>
>Exception Stack:
>Exception [TOPLINK-0] (Oracle TopLink - 10g release 2 (10.1.3.0.0)
>(Build 050902Dev)): oracle.toplink.exceptions.IntegrityException
>Descriptor Exceptions:
>---------------------------------------------------------
>Runtime Exceptions:
>---------------------------------------------------------
>java.util.NoSuchElementException: Hashtable Enumerator
>
>And also, I see the following exception in the same log
>
>java.util.NoSuchElementException: Hashtable Enumerator
> at java.util.Hashtable$Enumerator.nextElement(Hashtable.java:1010)
>
>Thanks,
>Sailaja
>
>Gordon Yorke wrote:
>
>
>
>>The advanced model in the entity-persistence-tests GlassFish module contains a PhoneNumber class that uses a composite PrimaryKey. The package is oracle.toplink.essentials.testing.models.advanced;
>>If you do not have access to the cvs modules send me an email directly and I will jar the source and send it to you.
>>--Gordon
>>
>>-----Original Message-----
>>From: aung zay [mailto:aungzay0_at_gmail.com]
>>Sent: Thursday, December 15, 2005 7:42 AM
>>To: persistence_at_glassfish.dev.java.net
>>Subject: help me with EJB3!
>>
>>
>>Hi,
>> Any of you having entity-persistence example of
>>one-to-many/many-to-one with composite key ?
>>Thanks in advance.
>>-AZ-
>>
>>
>>
>>
>>
>
>
>
>