RE: composite ID w/ another composite ID as a field

2007-04-03 Thread Pinaki Poddar
  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? 

afaik, Application identity classes like PageId are not enhanced in
current versions, they used to be.


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 [EMAIL PROTECTED] 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

RE: composite ID w/ another composite ID as a field

2007-04-03 Thread jeff
Pinaki Poddar [EMAIL PROTECTED] 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

Re: composite ID w/ another composite ID as a field

2007-04-02 Thread Craig L Russell

Hi Jeff,

The pattern you use for Book/Library is

public class BookId implements Serializable {
private String name;
private String library;


The pattern you use for Page/Book is

public class PageId implements Serializable {
private int number;
private BookId book;


Have you tried


public class PageId implements Serializable {
private int number;
private String book;


Craig

On Apr 2, 2007, at 10:41 AM, jeff wrote:

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 on your site using Yahoo! Search Marketing.
package com.mycompany.book;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;

@IdClass(com.mycompany.book.BookId.class)
@Entity
public class Book implements Serializable {
@Id
@Column(
name=BOOK_NAME,
nullable = false
)
@XmlAttribute (required = true)
private String name;

@OneToMany(
cascade = CascadeType.ALL,
mappedBy = book
)
@XmlElement (name = page)
private SetPage pages = new HashSetPage();

@Id
@Column(
nullable = false
)
@ManyToOne (
  cascade = CascadeType.ALL
)
private Library library;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Page getPage(int n) {
for (Page p: pages) {
if (p.getNumber() == n) {
return p;
}
}

return null;
}

public void putPage(Page p) {
p.setBook(this);
pages.add(p);
}

public boolean equals(Object o) {
if (!(o instanceof Book)) {
return false;
}

Book other = (Book)o;

if (!getName().equals(other.getName())) {
return false;
}

return true;
}

public int hashCode() {
return getName().hashCode();
}

public Library getLibrary() {
return library;
}

public void setLibrary(Library library) {
this.library = library;
}

}
package com.mycompany.book;

import java.io.Serializable;
import javax.xml.bind.annotation.XmlTransient;

@XmlTransient
public class BookId implements Serializable {
private String name;
private String library;


public boolean equals(Object o) {
if (!(o instanceof BookId)) {
return false;
}

BookId other = (BookId)o;

if (!(getName().equals(other.getName( {
return false;
}

if (!getLibrary().equals(other.getLibrary())) {
return false;
}

return true;
}

public int hashCode() {
return getName().hashCode() * getLibrary().hashCode();
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getLibrary() {
return library;
}

public void setLibrary(String library) {
this.library = library;
}
}
package com.mycompany.book;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;

RE: composite ID w/ another composite ID as a field

2007-04-02 Thread Pinaki Poddar
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 

Re: composite ID w/ another composite ID as a field

2007-04-02 Thread jeff
hi craig, thanks ...

your suggestion would imply that that BookId can be converted to and from a 
String object, right? i checked the spec, and i expected to find a requirement 
to have a toString() method and a string constructor that can work in unison to 
this end, but it's not there. maybe i am still thinking JDO.

anyway, i did try that, 

public class PageId implements Serializable {
private int number;
private String book;

and i get: 

Caused by: 4|true|0.9.6-incubating 
org.apache.openjpa.persistence.ArgumentException: The id class specified by 
type class com.mycompany.book.Page does not match the primary key fields of 
the class.  Make sure your identity class has the same primary keys as your 
persistent type, that the access types are the same, and if you are getting 
this error at runtime, that you have your persistent class since last compiling 
your identity class.
FailedObject: book [java.lang.String]

any ideas?

Craig L Russell [EMAIL PROTECTED] wrote: Hi Jeff,

The pattern you use for Book/Library is
 public class BookId implements Serializable {
 private String name;
 private String library;

The pattern you use for Page/Book is
 public class PageId implements Serializable {
 private int number;
 private BookId book;

Have you tried

 public class PageId implements Serializable {
 private int number;
 private String book;

Craig

On Apr 2, 2007, at 10:41 AM, jeff wrote:

 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 on your site using Yahoo! Search Marketing.
 package com.mycompany.book;

 import java.io.Serializable;
 import java.util.HashSet;
 import java.util.Set;
 import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.IdClass;
 import javax.persistence.ManyToOne;
 import javax.persistence.OneToMany;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;

 @IdClass(com.mycompany.book.BookId.class)
 @Entity
 public class Book implements Serializable {
 @Id
 @Column(
 name=BOOK_NAME,
 nullable = false
 )
 @XmlAttribute (required = true)
 private String name;

 @OneToMany(
 cascade = CascadeType.ALL,
 mappedBy = book
 )
 @XmlElement (name = page)
 private Set
 pages = new HashSet
();

 @Id
 @Column(
 nullable = false
 )
 @ManyToOne (
   cascade = CascadeType.ALL
 )
 private Library library;

 public String getName() {
 return name;
 }

 public void setName(String name) {
 this.name = name;
 }

 public Page getPage(int n) {
 for (Page p: pages) {
 if (p.getNumber() == n) {
 return p;
 }
 }

 return null;
 }

 public void putPage(Page p) {
 p.setBook(this);
 pages.add(p);
 }

 public boolean equals(Object o) {
 if (!(o instanceof Book)) {
 return false;
 }

 Book other = (Book)o;

 if (!getName().equals(other.getName())) {
 return false;
 }

 return true;
 }

 public int hashCode() {
 return getName().hashCode();
 }

 public Library getLibrary() {
 return library;
 }

 public void setLibrary(Library library) {
 this.library = library;
 }

 }
 package 

RE: composite ID w/ another composite ID as a field

2007-04-02 Thread jeff
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.java: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 [EMAIL PROTECTED] 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

RE: composite ID w/ another composite ID as a field

2007-04-02 Thread jeff
okay, by chance i looked at the open jpa pom and saw that it calls out surefire 
2.2 w/ some particular options. sure enough, that fixed the classpath problem.

however, i still get the exception w/ regard to ObjectId after making the 
changes you suggested ...

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:355)
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2382)

jeff [EMAIL PROTECTED] wrote: 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.java: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

RE: composite ID w/ another composite ID as a field

2007-04-02 Thread jeff
after doing some decompilation, the problem line is ...

PageId pageid = (PageId)((ObjectId)obj).getId();

in the enhanced Page class. so, looking at PageId, it's not an instance of 
ObjectId. so, i am not sure what is supposed to be happening here. i assume 
that PageId is supposed to be enhanced in some way. decompiling it shows that 
is not the case.

???

thanks.

jeff [EMAIL PROTECTED] wrote: okay, by chance i looked at the open jpa pom 
and saw that it calls out surefire 2.2 w/ some particular options. sure enough, 
that fixed the classpath problem.

however, i still get the exception w/ regard to ObjectId after making the 
changes you suggested ...

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:355)
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2382)

jeff  wrote: 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.java: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 

RE: composite ID w/ another composite ID as a field

2007-04-02 Thread Pinaki Poddar
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 [EMAIL PROTECTED] 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