Hi Jeff,
   I could reproduce the error on your test case. So please file a JIRA
issue. 


Pinaki Poddar
BEA Systems
415.402.7317  


-----Original Message-----
From: jeff [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 06, 2007 12:57 PM
To: open-jpa-dev@incubator.apache.org
Subject: RE: composite ID w/ another composite ID as a field

hi pinaki,

should i file an issue for this one? i can attach the failing test case
there.

thanks for your help.

jeff <[EMAIL PROTECTED]> wrote: Pinaki Poddar
 wrote:  > i can also pass along a maven2 project Can you post the Java
source of the test case and domain classes for us to reproduce the
error? 
i sent a .zip of the maven2 project to you directly. if there is a
better place to post it, let me know.

afaik, Application identity classes like PageId are not enhanced in
current versions, they used to be.
i did not see any difference between the decompiled Page and PageId
classes from the failed case, and the case that works when i remove the
book field from PageId (besides the obvious ones).

Pinaki Poddar
BEA Systems
415.402.7317  


-----Original Message-----
From: jeff [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 03, 2007 11:57 AM
To: open-jpa-dev@incubator.apache.org
Subject: RE: composite ID w/ another composite ID as a field

thanks pinaki,

as a test, i removed Page.book as an @Id, and made the corresponding
change in PageId (removed the book field of type PageId). this caused
the class cast exception below to go away. so, it does appear to have
some relation of to the use of the composite ID within a composite ID,
although you're right it might be a completely different issue.

this is with a trunk (as of this morning) build of openjpa.

i have attached the log you asked for. nothing stood out. i can also
pass along a maven2 project that contains the test case that fails if
that helps. i can't see to attach it here directly though as apache's
spam filter doesn't like it. let me know.

thanks again.

Pinaki Poddar
 wrote:

 Jeff,
 1. The errors look rather unrelated to original problem of composite
id.
 2. The errors apparently caused by enviroment setup, so please
 a) get a clean 0.9.7 openjpa (either building locally from the  source,
or pre-built jars from the openjpa web-site)
 b) if the error persists, report with trace-level logging  (property
name="openjpa.Log" value="DefaultLevel=TRACE"/>  and complete stack
trace.
 
 
 
 
 Pinaki Poddar
 BEA Systems
 415.402.7317 
 
 
 -----Original Message-----
 From: jeff [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 02, 2007 4:12 PM
 To: open-jpa-dev@incubator.apache.org
 Subject: RE: composite ID w/ another composite ID as a field
 
 thanks pinaki,
 
 after making those changes, on 0.9.6, i get:
 
 Caused by: java.lang.ClassCastException:
 org.apache.openjpa.util.ObjectId
 at com.mycompany.book.Page.pcCopyKeyFieldsToObjectId(Page.java)
 at
 
org.apache.openjpa.util.ApplicationIds.create(ApplicationIds.java:383)
 at
 
org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2349)
 
 i built the trunk locally, and mvn installed it into my local
repository. when i run against it, i get:
 
 Caused by: java.lang.RuntimeException: There were errors initializing
your configuration: org.apache.openjpa.lib.util.ParseException:
 Instantiation of plugin "QueryCompilationCache" with value "true"
caused  an error "java.lang.IllegalArgumentException:
 java.lang.ClassNotFoundException:
org.apache.openjpa.util.CacheMap". The
 alias or class name may have been misspelled (as it closely matches the
valid plugin alias "true"), or the class may not be available in the
class path. Valid aliases for this plugin are: [all, false, true]
 
 followed by:
 
 Caused by: java.lang.IllegalArgumentException:
 java.lang.ClassNotFoundException:
org.apache.openjpa.util.CacheMap
 at serp.util.Strings.toClass(Strings.java:211)
 at serp.util.Strings.toClass(Strings.java:140)
 at
 
org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.ja
 va:191)
 
 are there known issues w/ 0.9.7? what i don't understand is that
...CacheMap is in the sample place, in the same JAR as w/ the
0.9.6
 dependency, just in my local repository.
 
 also odd is that i only see the one info message during
enhancement:
 
 [java] 1268 book INFO [main] openjpa.Tool - No targets were  given.
Running on all classes in your persistent classes list, or all  metadata
files in classpath directories if you have not listed your  persistent
classes. Use -help to display tool usage information.
 
 no details are printed about the classes being enhanced.
obviously this
 was working in version 0,9.6.
 
 any ideas?
 
 Pinaki Poddar wrote: Hello Jeff,
 
 OpenJPA supports the cited example where Page using a composite ID
which  in turn refers to Book's composite ID. 
 
 Book/Page/Library classes work with
 a) openjpa-0.9.7 (do not know whether observed errors are due to usage
of earlier 0.9.6 version)
 b) following modifications in Page.book field (with a + sign)
 
 @Id
 @Column(nullable = false)
 @ManyToOne (cascade = CascadeType.ALL)
 + @JoinColumns({
 + @JoinColumn(name="book_library_LIBRARY_NAME",
 referencedColumnName="library_LIBRARY_NAME"),
 + @JoinColumn(name="book_BOOK_NAME",
 referencedColumnName="BOOK_NAME")
 })
 private Book book;
 
 
 where the JoinColumns specification refers to following schema (as per
your Page/Book/Library class annotations):
 
 mysql> desc book;
 
+----------------------+--------------+------+-----+---------+-------+
 | Field | Type | Null | Key | Default | Extra |
 
+----------------------+--------------+------+-----+---------+-------+
 | library_LIBRARY_NAME | varchar(255) | NO | PRI | NULL | |  |
BOOK_NAME | varchar(255) | NO | PRI | NULL | |
 
+----------------------+--------------+------+-----+---------+-------+
 mysql> desc page;
 
+---------------------------+--------------+------+-----+---------+-----
 --+
 | Field | Type | Null | Key | Default |  Extra |
 
+---------------------------+--------------+------+-----+---------+-----
 --+
 | book_library_LIBRARY_NAME | varchar(255) | NO | PRI | NULL |  |  |
book_BOOK_NAME | varchar(255) | NO | PRI | NULL |  |  | PAGE_NUMBER |
int(11) | NO | PRI | NULL |  |
 
+---------------------------+--------------+------+-----+---------+-----
 --+
 
 
 Without explicitly naming the join columns, following error is
 generated:
 
 Caused by: <4|true|0.9.7-incubating-SNAPSHOT>
 org.apache.openjpa.persistence.ArgumentException:
"crxxx.Page.book" does
 not supply a name for at least one declared column. Since this mapping
can involve multiple columns or uses constant joins, each column must
give either its name or a non-constant target.
 at
 
org.apache.openjpa.jdbc.meta.MappingInfo.mergeJoinColumn(MappingInfo.jav
 a:1372)
 at
 
org.apache.openjpa.jdbc.meta.MappingInfo.createJoins(MappingInfo.java:11
 86)
 at
 
org.apache.openjpa.jdbc.meta.MappingInfo.createForeignKey(MappingInfo.ja
 va:948)
 at
 
org.apache.openjpa.jdbc.meta.ValueMappingInfo.getTypeJoin(ValueMappingIn
 fo.java:101)
 at
 
org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.map(RelationFi
 eldStrategy.java:144)
 at
 
org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:
 117)
 at
 
org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(Ru
 ntimeStrategyInstaller.java:77)
 at
 
org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.ja
 va:435)
 at
 
org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:400)
 at
 
org.apache.openjpa.jdbc.meta.ClassMapping.resolveNonRelationMappings(Cla
 ssMapping.java:810)
 at
 
org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRep
 ository.java:316)
 at
 
org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository
 .java:602)
 at
 
org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.ja
 va:489)
 ... 24 more
 NestedThrowables:
 <4|true|0.9.7-incubating-SNAPSHOT>
 org.apache.openjpa.persistence.ArgumentException: Field
"crxxx.Book.pages" declares "crxxx.Page.book" as its mapped-by field,
but this field is not a direct relation.
 at
 
org.apache.openjpa.jdbc.meta.strats.RelationToManyInverseKeyFieldStrateg
 y.map(RelationToManyInverseKeyFieldStrategy.java:123)
 at
 
org.apache.openjpa.jdbc.meta.strats.RelationCollectionInverseKeyFieldStr
 ategy.map(RelationCollectionInverseKeyFieldStrategy.java:92)
 at
 
org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:
 117)
 at
 
org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(Ru
 ntimeStrategyInstaller.java:77)
 at
 
org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.ja
 va:435)
 at
 
org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:400)
 at
 
org.apache.openjpa.jdbc.meta.ClassMapping.resolveMapping(ClassMapping.ja
 va:781)
 at
 
org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1570)
 ...
 
 
 Pinaki Poddar
 BEA Systems
 415.402.7317 
 
 
 -----Original Message-----
 From: jeff [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 02, 2007 12:42 PM
 To: open-jpa-dev@incubator.apache.org
 Subject: composite ID w/ another composite ID as a field
 
 say i have Library, Book, and Page classes. a Library has many Books,
and a Book has many Pages. A Library's ID is it's name (simple).
A
 Book's ID is a composite of it's name and it's owning Library's name
(bidirectional relationship). A Page's ID is a composite of it's number
and it's owning Book's ID, a BookID.
 
 so, the PageId class starts like:
 
 public class PageId implements Serializable {  private int number;
private BookId book;
 
 the error i'm getting is at runtime ...
 
 <4|true|0.9.6-incubating>
 org.apache.openjpa.persistence.ArgumentException: Field
"com.mycompany.book.Book.pages" declares "com.mycompany.book.Page.book"
 as its mapped-by field, but this field is not a direct relation.
 
 first, is what i'm trying to do even valid? i suspect it is not, and
the  problem is that the fields of the ID class must be "simple"
types (i
 believe the spec demands that). although, the error message is a little
confusing so i am not sure.
 
 it occurs to me that another way to achieve this would be to add
bookName and libraryName fields to the Page class, and add a @PrePersist
method that populates them by calling book.getName() and
book.getLibrary().getName(). but again this is messy because that data
is already in the table because of the bidirectional relationship
between the objects.
 
 as always, i'm open to "what are you an idiot?" responses if i am just
going about trying to define the Library, Book, Page relationship in an
obtuse manner.
 
 classes attached.
 
 
 ________________________________
 
 The fish are biting.
 Get more visitors
 
sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50
 > on your site using Yahoo! Search Marketing.
 
sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50
 > 
 
 Notice: This email message, together with any attachments, may contain
information of BEA Systems, Inc., its subsidiaries and affiliated
entities, that may be confidential, proprietary, copyrighted and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.
 
 
 ---------------------------------
 Need Mail bonding?
 Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
 
 Notice: This email message, together with any attachments, may contain
information of BEA Systems, Inc., its subsidiaries and affiliated
entities, that may be confidential, proprietary, copyrighted and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.
 


________________________________

Food fight?
wOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&s
id=396545367>  Enjoy some healthy debate in the Yahoo! Answers Food &
Drink Q&A.
wOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&s
id=396545367> 

Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.



 
---------------------------------
No need to miss a message. Get email on-the-go with Yahoo! Mail for
Mobile. Get started.


 
---------------------------------
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.

Notice:  This email message, together with any attachments, may contain 
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated 
entities,  that may be confidential,  proprietary,  copyrighted  and/or legally 
privileged, and is intended solely for the use of the individual or entity 
named in this message. If you are not the intended recipient, and have received 
this message in error, please immediately return this by email and then delete 
it.

Reply via email to