Hello,
I have a number of domain objects that inherit from a abstract parent, that contains the persistence id (a Long).
I'm trying to map this in my orm.xml for use with OpenJpa like this:
I've tried all sorts of variations of <id>, <attribute-override>, access="FIELD" and access="PROPERTY" etc but keep getting the same error that "id" can't be found in my Customer class:Code:<?xml version="1.0"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd" version="1.0"> <persistence-unit-metadata> <xml-mapping-metadata-complete /> </persistence-unit-metadata> <mapped-superclass class="au.com.woolworths.ddd.domain.impl.AbstractDomainObject" access="FIELD"> <attributes> <version name="version"> <column name="ROW_VER_NO" /> </version> </attributes> </mapped-superclass> <mapped-superclass class="au.com.woolworths.ddd.domain.impl.AbstractDomainObjectLong" access="FIELD"> <attributes> <id name="id" /> </attributes> </mapped-superclass> <entity class="au.com.woolworths.inventory.customer.Customer" access="FIELD"> <table name="CUSTOMER" /> <sequence-generator name="CustSeq" sequence-name="CUST_SEQ" /> <attribute-override name="id"> <column name="CUSTOMER_ID" nullable="false" /> </attribute-override> <attributes> <id name="id"> <column name="CUSTOMER_ID" nullable="false" /> <generated-value strategy="SEQUENCE" generator="CustSeq" /> </id> </attributes> </entity> ... </entity-mappings>
I need to provide a different id sequence generator for each domain object, and have tried just specifing the id in each of the <entity> classes as well as without using attribute-override.Code:218 default INFO [main] openjpa.Runtime - Starting OpenJPA 0.9.7-incubating 968 default WARN [main] openjpa.Enhance - An exception was thrown while attempting to perform class file transformation on "au/com/woolworths/ddd/domain/impl/AbstractDomainObjectLong": <0.9.7-incubating nonfatal general error> org.apache.openjpa.util.GeneralException: org.xml.sax.SAXException: file:/C:/projects/wow-ref/wow-ref-core/target/classes/META-INF/orm.xml [Location: Line: 26, C: 18]: Could not find property/field with the name "id" in type "au.com.woolworths.inventory.customer.Customer". [java.lang.NoSuchFieldException: id] at org.apache.openjpa.persistence.PersistenceMetaDataFactory.parseXML(PersistenceMetaDataFactory.java:236)
id does not in exist in Customer but in the parent. In pure Hibermate mapping files, the inherited attributes are found with no problems, but am at a loss at the moment to provide the correct syntax. Note that I am not using annotaions at all in the domain object classes, I'm just using the entity mappings in the orm.xml
I'm new to JPA, so let me know if I'm missing something.
Thanks
Alan


Reply With Quote
