Nah, I think I have a good understanding of the issue. Certainly glad to hear that the issue is resolved.
Cheers, Andrus On Jul 24, 2012, at 7:51 AM, Kanwar Manish wrote: > Hi Andrus > > Although this is resolved for now. Do you want me to mail you another > schema and code where this is working? > > Thanks > Kanwar Manish > > On Tue, Jul 24, 2012 at 12:34 AM, Andrus Adamchik > <[email protected]>wrote: > >> From analyzing Kanwar's project, I was able to reproduce >> ClassCastException in an isolated unit test (see CAY-1728). The cause is >> essentially the same as FaultFailureException for the same mapping (more on >> that below). Whether ClassCastException or FaultFailureException is thrown >> depends on the order of internal iteration over properties for a given >> entity (the relative order of attributes and relationships in >> ClassDescriptor.getDeclaredProperties() which is driven by HashMap key >> hashing algorithm, i.e. completely obscure to the user). >> >> But ignore all that for a moment... The cause is that Cayenne is confused >> by mapping "redundancy" - there's a meaningful PK that uses custom type , >> and that same PK is used as a key in a to-many relationship (where Cayenne >> can't figure out custom type reliably, and uses default type). >> >> So what to do about it? We have a long term solution to change type >> mapping strategy that we are likely to implement in Cayenne 3.2: >> http://markmail.org/message/icr7seqazgsdtewc . Until that happens my >> advice would be to avoid using custom types for meaningful PKs. E.g. map it >> as a String and add a pair of extra methods to convert between String and >> UUID: >> >> // ignoring possibility of NULLs for a moment... >> public UUID getUserMasterUUID() { >> return UUID.fromString(getUserMasterId()); >> } >> >> public void setUserMasterUUID(UUID uuid) { >> setUserMasterId(uuid.toString()); >> } >> >> Not ideal, but should immediately solve your problem. And over time this >> will get fixed in Cayenne. >> >> Cheers, >> Andrus >> >> >> >> On Jul 23, 2012, at 10:20 AM, Kanwar Manish wrote: >> >>> Hi Andrus >>> >>> I am working on a small sample project with a new database. I will send >> you >>> the details shortly complete with all the details. >>> >>> For now - one tit-bit of information is that this problem doesn't seem >> to >>> be in 3.0.2 but in 3.1B1. >>> >>> Will mail shortly. >>> >>> Thanks >>> Manish >>> >>> On Sun, Jul 22, 2012 at 2:57 PM, Andrus Adamchik <[email protected] >>> wrote: >>> >>>> So we have 2 parallel mailing list thread discussing as I suspect the >> same >>>> underlying problem: >>>> >>>> 1. "Stumps me.....Error "java.lang.String cannot be cast to >>>> java.util.UUID" at http://markmail.org/thread/acngeble5stoywvl >>>> 2. "custom type stops working" at >>>> http://markmail.org/thread/3a6fx2iqjpor7aga >>>> >>>> This is an attempt to merge them into one and find the cause. >>>> >>>> I tried to reproduce the issue with Cayenne unit tests, but succeeded >> only >>>> partially: >>>> >>>> https://issues.apache.org/jira/browse/CAY-1728 >>>> >>>> I was using Cayenne 3.2-SNAPSHOT (this is trunk and should be nearly >>>> identical to 3.1B1). Reading and writing meaningful PK with custom type >>>> works as excepted. The problem I found is in reading to-one relationship >>>> pointing to a meaningful PK with custom type. But I could not reproduce >> a >>>> ClassCastException. >>>> >>>> Arturo, Kanwar, would it be possible to provide me with the full mapping >>>> of a failing entity and all its relationships, and a piece of code that >>>> leads to ClassCastException (via CAY-1728 Jira or directly via email if >> you >>>> don't want to expose your project mapping) ? If you can build a small >>>> standalone test (Junit or just main(..)) it will be extremely helpful. >>>> >>>> Thanks, >>>> Andrus >>>> >>>> >>>> >> >>
