My apologies in advance for a long email. I have tried to simplify the
problem decsription as best as possible and have searched archives and
read the spec. Thanks in advance for your help.
I am migrating my application from using JDBC to using Java Persistence
API. The schema is fixed by an ISO standard (cannot be changed) and
represents the relational mapping of an OO model with inheritance semantics.
A simplified version of the inheritance Model is shown here:
http://ebxmlrr.sourceforge.net/tmp/Simplifiedclassdiagram.png
The UML diagram is mapped to the schema such that:
-Each leaf class (Oragnization, and Classification) has its own table
-There is no table defined for the base class RegistryObject
-All base class attributes are duplicated in the leaf class table
-A View is defined for the base class RegistryObject which allows for
querying at the base class level.
-The base class has a collection of composed (Embedded) object Property
which uses a composite id and has a foreign key to join with the parent
Leaf class (Organization or Classification).
-The base class has a collection of composed object (but not embedded
from a relational standpoint) Classification which uses a foreign key to
join with the parent Leaf class (Organization or Classification).
A simplified version schema is as follows:
CREATE TABLE Organization (
id VARCHAR(256) NOT NULL PRIMARY KEY,
...
);
CREATE TABLE Classification (
id VARCHAR(256) NOT NULL PRIMARY KEY,
--Foreign key to parent RegistryObject being classified by this object
classifiedObject VARCHAR(256) NOT NULL,
...
);
CREATE TABLE Property (
--Multiple rows of Property make up a single Property to support
--collection of values in a single logical Property
--The sequenceid is to keep the collection of values ordered
sequenceId INT NOT NULL,
name_ VARCHAR(256) NOT NULL,
value VARCHAR(256),
--The parent RegistryObject that this is a Property for
parent VARCHAR(256) NOT NULL,
PRIMARY KEY (parent, name_, sequenceId)
);
CREATE VIEW Identifiable (
--Base class Attributes
id,
...
) AS
SELECT
id,
...
FROM Organization
UNION ALL
SELECT
id,
...
FROM Person
The Entity classes I have defined for above schema are as follows:
@MappedSuperclass
public abstract class RegistryObject implements Serializable {
@Id
@Column(name = "ID", nullable = false)
protected String id;
@OneToMany (mappedBy="parent", cascade={CascadeType.REMOVE,
CascadeType.PERSIST})
private Collection<Property> properties;
@OneToMany (mappedBy="classifiedObject",
cascade={CascadeType.REMOVE, CascadeType.PERSIST})
protected Collection<Classification> classifications;
....accessor methods....
}
@MappedSuperclass
public abstract class RegistryObject implements Serializable {
@Id
@Column(name = "ID", nullable = false)
protected String id;
@OneToMany (mappedBy="parent", cascade={CascadeType.REMOVE,
CascadeType.PERSIST})
private Collection<Property> properties;
....accessor methods....
}
@Entity
@Table(name = "SERVICE")
public class Organization extends RegistryObject {
...
}
@Entity
@Table(name = "CLASSIFICATION")
public class Classification extends RegistryObject {
@ManyToOne
@JoinColumn(name = "CLASSIFIEDOBJECT", referencedColumnName = "id",
table = "RegistryObject", nullable = false)
private String classifiedObject;
...
}
@Entity
@Table(name = "PROPERTY")
public class Property implements Serializable {
@EmbeddedId
protected PropertyPK PropertyPK;
@Column(name = "VALUE")
private String value;
...
}
@Embeddable
public class PropertyPK implements Serializable {
@Id
@Column(name = "SEQUENCEID", nullable = false)
private int sequenceid;
@Id
@Column(name = "NAME_", nullable = false)
private String name;
@Id
@ManyToOne
@JoinColumn(name = "PARENT", referencedColumnName = "id", table =
"RegistryObject", nullable = false)
private String parent;
...
}
The Problem:
I get a validation exception when I try an insert operation. I am sure
that I am doing something wrong but not sure how to fix it. Thanks for
your help.
[TopLink Finest]: 2006.09.13
10:35:04.760--ServerSession(207002720)--Thread(Thread[main,5,main])--property=toplink.weaving;
value=false
[TopLink Config]: 2006.09.13
10:35:05.199--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Federation] is being
defaulted to: Federation.
[TopLink Config]: 2006.09.13
10:35:05.294--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.ClassificationNode]
is being defaulted to: ClassificationNode.
[TopLink Config]: 2006.09.13
10:35:05.308--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.RegistryPackage] is
being defaulted to: RegistryPackage.
[TopLink Config]: 2006.09.13
10:35:05.317--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Association] is
being defaulted to: Association.
[TopLink Config]: 2006.09.13
10:35:05.357--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.AffectedObject] is
being defaulted to: AffectedObject.
[TopLink Config]: 2006.09.13
10:35:05.420--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Organization] is
being defaulted to: Organization.
[TopLink Config]: 2006.09.13
10:35:05.425--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.ExternalLink] is
being defaulted to: ExternalLink.
[TopLink Config]: 2006.09.13
10:35:05.428--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.AdhocQuery] is being
defaulted to: AdhocQuery.
[TopLink Config]: 2006.09.13
10:35:05.430--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.ExternalIdentifier]
is being defaulted to: ExternalIdentifier.
[TopLink Config]: 2006.09.13
10:35:05.437--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Notification] is
being defaulted to: Notification.
[TopLink Config]: 2006.09.13
10:35:05.440--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Person] is being
defaulted to: Person.
[TopLink Config]: 2006.09.13
10:35:05.445--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Name] is being
defaulted to: Name.
[TopLink Config]: 2006.09.13
10:35:05.482--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Registry] is being
defaulted to: Registry.
[TopLink Config]: 2006.09.13
10:35:05.493--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Description] is
being defaulted to: Description.
[TopLink Config]: 2006.09.13
10:35:05.495--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.User] is being
defaulted to: User.
[TopLink Config]: 2006.09.13
10:35:05.498--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.ServiceBinding] is
being defaulted to: ServiceBinding.
[TopLink Config]: 2006.09.13
10:35:05.500--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Service] is being
defaulted to: Service.
[TopLink Config]: 2006.09.13
10:35:05.502--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.UsageDescription] is
being defaulted to: UsageDescription.
[TopLink Config]: 2006.09.13
10:35:05.514--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Classification] is
being defaulted to: Classification.
[TopLink Config]: 2006.09.13
10:35:05.610--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.ExtrinsicObject] is
being defaulted to: ExtrinsicObject.
[TopLink Config]: 2006.09.13
10:35:05.619--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.ObjectRef] is being
defaulted to: ObjectRef.
[TopLink Config]: 2006.09.13
10:35:05.621--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.SpecificationLink]
is being defaulted to: SpecificationLink.
[TopLink Config]: 2006.09.13
10:35:05.626--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.ClassificationScheme]
is being defaulted to: ClassificationScheme.
[TopLink Config]: 2006.09.13
10:35:05.629--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Subscription] is
being defaulted to: Subscription.
[TopLink Config]: 2006.09.13
10:35:05.633--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.AuditableEvent] is
being defaulted to: AuditableEvent.
[TopLink Config]: 2006.09.13
10:35:05.640--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.Slot] is being
defaulted to: Slot.
[TopLink Config]: 2006.09.13
10:35:05.645--ServerSession(207002720)--Thread(Thread[main,5,main])--The
alias name for the entity class [class
org.freebxml.omar.server.persistence.rdb.entitybean.NotificationObject]
is being defaulted to: NotificationObject.
[TopLink Config]: 2006.09.13
10:35:05.773--ServerSession(207002720)--Thread(Thread[main,5,main])--The
target entity (reference) class for the one to many mapping element
[private java.util.Collection
org.freebxml.omar.server.persistence.rdb.entitybean.Identifiable.slots]
is being defaulted to: class
org.freebxml.omar.server.persistence.rdb.entitybean.Slot.
[TopLink Config]: 2006.09.13
10:35:05.777--ServerSession(207002720)--Thread(Thread[main,5,main])--The
target entity (reference) class for the many to one mapping element
[private java.lang.String
org.freebxml.omar.server.persistence.rdb.entitybean.SlotPK.parent] is
being defaulted to: class java.lang.String.
E
Time: 2.746
There was 1 error:
1)
testInsert(org.freebxml.omar.server.persistence.rdb.SQLPersistenceManagerTest)Local
Exception Stack:
Exception [TOPLINK-7243] (Oracle TopLink Essentials - 2006.8 (Build
060829)): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Missing meta data for class [java.lang.String].
Ensure the class is not being excluded from your persistence unit by a
<exclude-unlisted-classes>true</exclude-unlisted-classes> setting. If
this is the case, you will need to include the class directly by adding
a <class>[java.lang.String]</class> entry for your persistence-unit.
at
oracle.toplink.essentials.exceptions.ValidationException.classNotListedInPersistenceUnit(ValidationException.java:2120)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.getDescriptor(MetadataProject.java:253)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.MetadataAccessor.getReferenceDescriptor(MetadataAccessor.java:283)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ObjectAccessor.processOneToOneForeignKeyRelationship(ObjectAccessor.java:107)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ObjectAccessor.processOwningMappingKeys(ObjectAccessor.java:92)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ManyToOneAccessor.process(ManyToOneAccessor.java:73)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:250)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor.getMappingForAttributeName(MetadataDescriptor.java:441)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor.getMappingForAttributeName(MetadataDescriptor.java:450)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.getOwningMapping(RelationshipAccessor.java:121)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.OneToManyAccessor.process(OneToManyAccessor.java:104)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.RelationshipAccessor.processRelationship(RelationshipAccessor.java:250)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.processRelationshipDescriptors(MetadataProject.java:513)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProject.process(MetadataProject.java:445)
at
oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:203)
at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.processORMetadata(EntityManagerSetupImpl.java:993)
at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:501)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.callPredeploy(JavaSECMPInitializer.java:145)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initPersistenceUnits(JavaSECMPInitializer.java:225)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:240)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initializeFromMain(JavaSECMPInitializer.java:277)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.getJavaSECMPInitializer(JavaSECMPInitializer.java:80)
at
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:118)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at
org.freebxml.omar.server.persistence.rdb.SQLPersistenceManager.<init>(SQLPersistenceManager.java:46)
at
org.freebxml.omar.server.persistence.rdb.SQLPersistenceManagerTest.testInsert(SQLPersistenceManagerTest.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
--
Regards,
Farrukh
Web: http://www.wellfleetsoftware.com