persistence@glassfish.java.net

Re: help me with EJB3!

From: aung zay <aungzay0_at_gmail.com>
Date: Wed, 21 Dec 2005 16:07:16 +0630

hi,
May i know if glassfish had issue with one to one mapping b4 20th dec
nightly build?
If its had one, it is already fixed on latest build.
Thanks
-AZ-

On 12/20/05, Gordon Yorke <gordon.yorke_at_oracle.com> wrote:
>
> I took a quick look, there doesn't appear to be anything wrong with the
> classes. There have been some bugs with the compound primary key code that
> has been fixed recently. I recommend getting the latest code from the
> entity-perstence module.
> --Gordon
>
>
> -----Original Message-----
> From: Markus Fuchs [mailto:Markus.Fuchs_at_Sun.COM]
> Sent: Friday, December 16, 2005 3:55 PM
> To: aung zay
> Cc: Gordon Yorke
> Subject: Re: help me with EJB3!
>
>
> Hi AZ,
>
> I can't see anything wrong w/ your classes. Why did you comment out the
> get/setPK in CustomerComposite? Did this affect the error?
>
> Gordon,
>
> Please have a look at the attached jar. The error message is:
>
> 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 also note that Aung seems to be using an older TopLink Essentials
> version.
>
> Thanks!
>
> -- markus.
>
> > Hi Markus,
> > Thanks for the comments.sorry about the attachment.
> > Now I send again.
> > I m afraid that you wanna see my code.
> > Thanks
> > -AZ-
> >
> > Markus Fuchs wrote:
> >
> >> Hi AZ,
> >>
> >> Please find my comments in line!
> >>
> >> aung zay wrote:
> >>
> >>> hi Markus Fuchs,
> >>>
> >>> I m not sure my code is correct or not. All i have are EJB-3
> >>> draft docs.
> >>> Let me know if there any good sample or link to learn EJB3
> >>> I attached my code as jar so that you can check.
> >>
> >>
> >>
> >>
> >> The email I got did not have an attachment...
> >>
> >>> Thanks
> >>> -AZ-
> >>>
> >>> Markus Fuchs wrote:
> >>>
> >>>> Hi AZ,
> >>>>
> >>>> the two relationships below don't seem inverse to each other. Are
> >>>> they the two sides of the same relationship?
> >>>>
> >>
> >> Please disregard above sentence. I was first confused about the
> >> relationship when I started composing my reply and then forgot to
> >> remove it before I send the email. The relationship below looks
> >> perfectly fine to me. It is that a CustomerComposite can have a
> >> Collection of OrderComposite, right?
> >>
> >>>> aung zay wrote:
> >>>>
> >>>>> 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;
> >>>>> }
> >>>>>
> >>>> This is defined in OrderComposite, correct?
> >>>>
> >>>>> OrderComposite
> >>>>> -----------------
> >>>>> id -PK
> >>>>>
> >>>>> @OneToMany( cascade=CascadeType.ALL ,fetch = FetchType.EAGER,
> >>>>> mappedBy="customer") public Collection<OrderComposite>
> >>>>> getOrders() {
> >>>>> return orders;
> >>>>> }
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> This is defined in CustomerComposite, correct?
> >>>>
> >>>> The mapping looks correct to me. Do you have any other relationship
> >>>> in OrderComposite mapped to ORDERCOMPOSITE.CUSTOMER_ID /
> >>>> ORDERCOMPOSITE.CUSTOMER_NAME?
> >>>
> >>>
> >>>
> >>
> >> This was my comment on the exception you saw:
> >>
> >> [...
> >> 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.
> >> ...]
> >>
> >> Please check, if there is another relationship mapped to the foreign
> >> key columns ORDERCOMPOSITE.CUSTOMER_ID or
> >> ORDERCOMPOSITE.CUSTOMER_NAME. Are these columns mapped in any other
> way?
> >>
> >>>>
> >>>> -- markus.
> >>>>
> >>>>
> >>>>> 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
> >>>>>>
> >>
> >> Mitesh is right. referencedColumnName should be "branch_id",as
> >> Employee's PK is (id, branch_id) and not (id, name).
> >>
> >> Thanks,
> >>
> >> -- markus.
> >>
> >>>>>>> @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-
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>
> >>
> >
>
>
>