Hi Mitesh Meswani,
Oops, Sorry, wrong log msg. The even though the code is the samilar.
By the way, it worked on M-M case. why not on 1-M/M-1?
CustomerComposite
---------------------
id - PK
name -PK
@ManyToOne( cascade= {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinColumns({
@JoinColumn(name = "CUSTOMER_ID" ,referencedColumnName="id"),
@JoinColumn(name = "CUSTOMER_NAME",referencedColumnName="name")
})
public CustomerComposite getCustomer() {
return customer;
}
OrderComposite
-----------------
id -PK
@OneToMany( cascade=CascadeType.ALL ,fetch = FetchType.EAGER,
mappedBy="customer")
public Collection<OrderComposite> getOrders() {
return orders;
}
Thanks
-AZ-
Mitesh Meswani wrote:
> Hi AZ,
>
> The error you are getting is coming from
> com.jumino.entity.OrderComposite --> [DatabaseTable(ORDERCOMPOSITE)].
> I guess it has nothing to do with Employee or PhoneNumber objects.
> Please see inline....
>
> aung zay wrote:
>
>> 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"),
>>
>
>
> //I think you want to refer to "branch_id" from Employee and not
> "name" as below
>
>> @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.
>
>
> Please check the mapping as suggested by error message above
>
> Thanks,
> Mitesh
>
>> 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-
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>