hi,
2.0-b56, i'm seeing this ...
/Exception Description: Invalid composite primary key specification. The
names of the primary key fields or properties in the primary key class
[com.sun.portal.pom.EntityId] and those of the entity bean class [class
com.sun.portal.pom.Entity] must correspond and their types must be the
same. Also, ensure that you have specified id elements for the
corresponding attributes in XML and/or an @Id on the corresponding
fields or properties of the entity class.
/
i've attached the two classes. Entity has IDs /name/ and /page/, and
EntityId has fields /name/ and /page/. same name, same type. i can zip
the maven2 project so the problem can be reproduced, if that helps.
what am i missing?
thanks.
package com.sun.portal.pom;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
@IdClass (com.sun.portal.pom.EntityId.class)
@javax.persistence.Entity
@Inheritance (strategy = InheritanceType.JOINED)
public abstract class Entity implements Serializable {
@Id
@Column (nullable = false, name="ENTITY_NAME")
@XmlAttribute
private String name;
@Id
@Column (nullable = false)
@ManyToOne (cascade = CascadeType.ALL)
private Page page = null;
@Column (nullable = false)
@XmlElement (
name = "portlet-name"
)
private String portletName;
public String getPortletName() {
return portletName;
}
public void setPortletName(String portletName) {
this.portletName = portletName;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public abstract String getPortletType();
public abstract Preferences getPreferences();
public boolean equals(Object o) {
if (!(o instanceof Entity)) {
return false;
}
Entity other = (Entity)o;
EntityId id = new EntityId(this);
EntityId otherId = new EntityId(other);
return id.equals(otherId);
}
public int hashCode() {
return new EntityId(this).hashCode();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.sun.portal.pom;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlTransient;
@XmlTransient
public class EntityId implements Serializable {
private String name;
private Page page;
public EntityId() { }
public EntityId(Entity e) {
this.name = e.getName();
this.page = e.getPage();
}
public boolean equals(Object o) {
EntityId other = (EntityId)o;
if (!getName().equals(other.getName())) {
return false;
}
if (other.getPage() == null) {
return false;
}
if (!getPage().equals(other.getPage())) {
return false;
}
return true;
}
public int hashCode() {
return toString().hashCode();
}
public String toString() {
String s = getPage().getName() + ":" + getName();
return s;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
}