Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » @Id and @AttributeOverride
@Id and @AttributeOverride [message #945187] Mon, 15 October 2012 05:30 Go to next message
Eclipse UserFriend
I have an abstract class annotated as @MappedSuperclass with attribute @Id and an @Entity class that inherits from that abstract class. I want to use the attribute from the superclass in the inherited class and override the column's name in the database. I did it as follows in orm.xml:

<entity-mappings ...

<mapped-superclass class="abstract.SuperClass">
   ...  
   <attributes>
      <id name="id"><generated-value strategy="AUTO"/></id>
      ...
   </attributes>
</mapped-superclass>

<entity class="entity.InheritedClass" access="FIELD">
   ...
   <attribute-override name="id"><column name="INHERITED_CLASS_ID column-definition="BIGINT"/></attribute-override>
   ...
</entity>


Running this example throws the following exception:

javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [herakles] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class ch.eugster.herakles.persistence.model.TectonicsLevel] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1441)
	at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:208)
	at org.apache.aries.jpa.eclipselink.adapter.EclipseLinkProviderService$1.createContainerEntityManagerFactory(EclipseLinkProviderService.java:70)
	at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:329)
	at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:175)
	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.setupManager(PersistenceBundleManager.java:394)
	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.addingService(PersistenceBundleManager.java:209)
	at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932)
	at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)
	at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
	at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:894)
	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
	at org.apache.aries.jpa.eclipselink.adapter.Activator.handlePotentialEclipseLink(Activator.java:127)
	at org.apache.aries.jpa.eclipselink.adapter.Activator.start(Activator.java:80)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
	at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [herakles] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class ch.eugster.herakles.persistence.model.TectonicsLevel] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
	at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:221)
	... 39 more
Caused by: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class ch.eugster.herakles.persistence.model.TectonicsLevel] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
	at org.eclipse.persistence.exceptions.ValidationException.noPrimaryKeyAnnotationsFound(ValidationException.java:1392)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.validatePrimaryKey(EntityAccessor.java:1336)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processMappingAccessors(EntityAccessor.java:1067)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:631)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1685)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:532)
	at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:546)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1376)
	... 38 more


Question: is it not possible to override the attribute @Id? Is it mandatory, that I use for every @Entity an own attribute @Id?

Thank you!
Re: @Id and @AttributeOverride [message #945633 is a reply to message #945187] Mon, 15 October 2012 09:48 Go to previous messageGo to next message
Eclipse UserFriend
That's interesting, what it is saying is that it doesn't find the id attribute at all (let alone the override).

What happens if you put access="FIELD" on the mapped superclass?

Can you post your model classes as well?

Re: @Id and @AttributeOverride [message #945661 is a reply to message #945633] Mon, 15 October 2012 10:05 Go to previous messageGo to next message
Eclipse UserFriend
Hi Guy,

thank you for answering! Here my persistence.xml, orm.xml and the classes:

First, my persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
	<persistence-unit name="herakles" transaction-type="JTA">
		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

 		<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/xaheraklesdb)</jta-data-source>
 		<non-jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/heraklesdb)</non-jta-data-source>

		<mapping-file>META-INF/orm.xml</mapping-file>

		<class>ch.eugster.herakles.persistence.model.AbstractEntity</class>
		<class>ch.eugster.herakles.persistence.model.Agent</class>
		<class>ch.eugster.herakles.persistence.model.AgentProperty</class>
        <class>ch.eugster.herakles.persistence.model.Tectonics</class>
 		<class>ch.eugster.herakles.persistence.model.TectonicsLevel</class>
		<class>ch.eugster.herakles.persistence.model.TectonicsLevelLink</class>
	
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
		<properties>
<!--             <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/test"/>
            <property name="javax.persistence.jdbc.user" value="root"/>
            <property name="javax.persistence.jdbc.password" value=""/> -->
            <property name="osgi.unit.name" value="herakles"/>
            <property name="osgi.unit.version" value="1.0.0"/>
            <property name="osgi.unit.provider" value="org.eclipse.persistence.jpa.PersistenceProvider"/>
            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
            <property name="eclipselink.logging.level" value="FINEST"/>
			<property name="eclipselink.weaving" value="false"/>
		</properties>
	</persistence-unit>
</persistence>


Then my orm.xml
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="2.3" xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_4.xsd">
	<persistence-unit-metadata>
 	<persistence-unit-defaults>
			<access>FIELD</access>
		</persistence-unit-defaults>
	</persistence-unit-metadata>
	<object-type-converter name="booleanConverter" data-type="java.lang.Integer" object-type="java.lang.Boolean"><conversion-value data-value="0" object-value="false"/><conversion-value data-value="1" object-value="true"/><default-object-value>true</default-object-value></object-type-converter>
 
 	<mapped-superclass class="ch.eugster.persistence.model.AbstractEntity" access="FIELD">
		<pre-persist method-name="prePersist"></pre-persist>
		<pre-update method-name="preUpdate"></pre-update>
		<attributes>
			<id name="id"><generated-value strategy="AUTO"/></id>
			<basic name="persisted"><temporal>TIMESTAMP</temporal></basic>
			<basic name="updated"><temporal>TIMESTAMP</temporal></basic>
			<basic name="deleted"><convert>booleanConverter</convert></basic>
			<version name="version"></version>
			<one-to-one name="agent"></one-to-one>
			<transient name="propertyChangeSupport"/>
		</attributes>
	</mapped-superclass>

    <entity class="ch.eugster.herakles.persistence.model.Tectonics" name="Tectonics" access="FIELD">
        <table name="HERAKLES_TECTONICS"/>
        <table-generator name="TECTONICS_SEQ" table="HERAKLES_SEQUENCE"></table-generator>

        <entity-listeners>
            <entity-listener class="ch.eugster.herakles.persistence.event.TectonicsListener"></entity-listener>
        </entity-listeners>

        <attribute-override name="id"><column name="TECTONICS_ID" column-definition="BIGINT"/></attribute-override>
        <attribute-override name="persisted"><column name="TECTONICS_PERSISTED" column-definition="TIMESTAMP"/></attribute-override >
        <attribute-override name="updated"><column name="TECTONICS_UPDATED" column-definition="TIMESTAMP"/></attribute-override >
        <attribute-override name="version"><column name="TECTONICS_VERSION" column-definition="INTEGER"/></attribute-override >
        <attribute-override name="deleted"><column name="TECTONICS_DELETED" column-definition="SMALLINT"/></attribute-override >

        <association-override name="agent"><join-column name="TECTONICS_AGENT_ID" column-definition="BIGINT"/></association-override>

        <attributes>
            <basic name="name"><column name="TECTONICS_NAME" column-definition="VARCHAR(255)"/></basic>
            <basic name="image"><column name="TECTONICS_IMAGE"/><lob/></basic>
            <basic name="description"><column name="TECTONICS_DESCRIPTION" /><lob/></basic>
             <one-to-many name="levels" mapped-by="tectonics"><cascade><cascade-all/></cascade></one-to-many>
        </attributes>
    </entity>

     <entity class="ch.eugster.herakles.persistence.model.TectonicsLevel" name="TectonicsLevel" access="FIELD">
        <table name="HERAKLES_TECTONICS_LEVEL"/>
        <table-generator name="TECTONICS_LEVEL_SEQ" table="HERAKLES_SEQUENCE"></table-generator>

        <entity-listeners>
            <entity-listener class="ch.eugster.herakles.persistence.event.TectonicsLevelListener"></entity-listener>
        </entity-listeners>

        <attribute-override name="id"><column name="TECTONICS_LEVEL_ID" column-definition="BIGINT"/></attribute-override>
        <attribute-override name="persisted"><column name="TECTONICS_LEVEL_PERSISTED" column-definition="TIMESTAMP"/></attribute-override >
        <attribute-override name="updated"><column name="TECTONICS_LEVEL_UPDATED" column-definition="TIMESTAMP"/></attribute-override >
        <attribute-override name="version"><column name="TECTONICS_LEVEL_VERSION" column-definition="INTEGER"/></attribute-override >
        <attribute-override name="deleted"><column name="TECTONICS_LEVEL_DELETED" column-definition="SMALLINT"/></attribute-override >

        <association-override name="agent"><join-column name="TECTONICS_LEVEL_AGENT_ID" column-definition="BIGINT"/></association-override>

        <attributes>
            <basic name="name"><column name="TECTONICS_LEVEL_NAME" column-definition="VARCHAR(255)"/></basic>
            <basic name="image"><column name="TECTONICS_LEVEL_IMAGE"/><lob/></basic>
            <basic name="description"><column name="TECTONICS_LEVEL_DESCRIPTION" /><lob/></basic>
            <one-to-many name="children" mapped-by="parent"><cascade><cascade-all/></cascade></one-to-many>
        </attributes>
    </entity>

    <entity class="ch.eugster.herakles.persistence.model.TectonicsLevelLink" name="TectonicsLevelLink" access="FIELD">
        <table name="HERAKLES_TECTONICS_LEVEL_LINK"/>
        <table-generator name="TECTONICS_LEVEL_LINK_SEQ" table="HERAKLES_SEQUENCE"></table-generator>

        <entity-listeners>
            <entity-listener class="ch.eugster.herakles.persistence.event.TectonicsLevelLinkListener"></entity-listener>
        </entity-listeners>

        <attribute-override name="id"><column name="TECTONICS_LEVEL_LINK_ID" column-definition="BIGINT"/></attribute-override>
        <attribute-override name="persisted"><column name="TECTONICS_LEVEL_LINK_PERSISTED" column-definition="TIMESTAMP"/></attribute-override >
        <attribute-override name="updated"><column name="TECTONICS_LEVEL_LINK_UPDATED" column-definition="TIMESTAMP"/></attribute-override >
        <attribute-override name="version"><column name="TECTONICS_LEVEL_LINK_VERSION" column-definition="INTEGER"/></attribute-override >
        <attribute-override name="deleted"><column name="TECTONICS_LEVEL_LINK_DELETED" column-definition="SMALLINT"/></attribute-override >

        <association-override name="agent"><join-column name="TECTONICS_LEVEL_LINK_AGENT_ID" column-definition="BIGINT"/></association-override>

        <attributes>
            <many-to-one name="parent"><join-column name="TECTONICS_LEVEL_LINK_PARENT_ID" column-definition="BIGINT"/></many-to-one>
            <one-to-one name="child"><join-column name="TECTONICS_LEVEL_LINK_CHILD_ID" column-definition="BIGINT"/></one-to-one>
        </attributes>
    </entity>

    <entity class="ch.eugster.herakles.persistence.model.Agent" name="Agent" access="FIELD">
        <table name="HERAKLES_AGENT"/>
        <table-generator name="AGENT_SEQ" table="HERAKLES_SEQUENCE"></table-generator>

        <entity-listeners>
            <entity-listener class="ch.eugster.persistence.event.AgentListener"></entity-listener>
        </entity-listeners>

        <attribute-override name="id"><column name="AGENT_ID" column-definition="BIGINT"/></attribute-override>
        <attribute-override name="persisted"><column name="AGENT_PERSISTED" column-definition="TIMESTAMP"/></attribute-override >
        <attribute-override name="updated"><column name="AGENT_UPDATED" column-definition="TIMESTAMP"/></attribute-override >
        <attribute-override name="version"><column name="AGENT_VERSION" column-definition="INTEGER"/></attribute-override >
        <attribute-override name="deleted"><column name="AGENT_DELETED" column-definition="SMALLINT"/></attribute-override >

        <association-override name="agent"><join-column name="AGENT_AGENT_ID" column-definition="BIGINT"/></association-override>

        <attributes>
            <basic name="fullname"><column name="AGENT_FULLNAME" column-definition="VARCHAR(255)"/></basic>
            <basic name="username"><column name="AGENT_USERNAME" column-definition="VARCHAR(255)"/></basic>
            <basic name="password"><column name="AGENT_PASSWORD" column-definition="VARCHAR(255)"/></basic>
            <basic name="state"><column name="AGENT_STATE" column-definition="INTEGER"/><enumerated>ORDINAL</enumerated></basic>
        </attributes>
    </entity>

    <entity class="ch.eugster.herakles.persistence.model.AgentProperty" name="AgentProperty" access="FIELD">
        <table name="HERAKLES_AGENT_PROPERTY"/>
        <table-generator name="AGENT_PROPERTY_SEQ" table="HERAKLES_SEQUENCE"></table-generator>

        <entity-listeners>
            <entity-listener class="ch.eugster.persistence.event.AgentPropertyListener"></entity-listener>
        </entity-listeners>

        <attribute-override name="id"><column name="AGENT_PROPERTY_ID" column-definition="BIGINT"/></attribute-override>
        <attribute-override name="persisted"><column name="AGENT_PROPERTY_PERSISTED" column-definition="TIMESTAMP"/></attribute-override >
        <attribute-override name="updated"><column name="AGENT_PROPERTY_UPDATED" column-definition="TIMESTAMP"/></attribute-override >
        <attribute-override name="version"><column name="AGENT_PROPERTY_VERSION" column-definition="INTEGER"/></attribute-override >
        <attribute-override name="deleted"><column name="AGENT_PROPERTY_DELETED" column-definition="SMALLINT"/></attribute-override >

        <association-override name="agent"><join-column name="AGENT_PROPERTY_AGENT_ID" column-definition="BIGINT"/></association-override>

        <attributes>
            <basic name="key"><column name="AGENT_PROPERTY_KEY" column-definition="VARCHAR(255)"/></basic>
            <basic name="value"><column name="AGENT_PROPERTY_VALUE"/><lob/></basic>
            <many-to-one name="agent"><join-column name="AGENT_PROPERTY_AGENT_ID" column-definition="BIGINT"/></many-to-one>
        </attributes>
    </entity>
</entity-mappings>


Then my AbstractEntity.class
package ch.eugster.herakles.persistence.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.math.BigInteger;
import java.util.Calendar;

public abstract class AbstractEntity<E extends IEntity<E>> implements IEntity<E>
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static boolean isId(final BigInteger id)
	{
		return id != null && id.longValue() > 0L;
	}

	protected static IEntity<?> newInstance(final IEntity<?> entity)
	{
		return entity;
	}

	protected PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);

	protected BigInteger id;

	protected Calendar persisted;

	protected Calendar updated;

	protected int version;

	protected boolean deleted;

	private Agent agent;
	
	public AbstractEntity()
	{
		super();
	}

	public void addPropertyChangeListener(final String propertyName, final PropertyChangeListener listener)
	{
		propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
	}

	protected IEntity<E> copy(final IEntity<E> entity)
	{
		entity.setId(getId());
		entity.setPersisted(getPersisted());
		entity.setUpdated(getUpdated());
		entity.setDeleted(isDeleted());
		return entity;
	}

	@Override
	public boolean equals(final Object other)
	{
		if (other instanceof IEntity)
		{
			@SuppressWarnings("unchecked")
			final IEntity<E> entity = (IEntity<E>) other;
			if (entity.getId() != null && getId() != null)
			{
				return entity.getId().equals(getId());
			}
			return entity.hashCode() == hashCode();
		}
		return false;
	}

	public BigInteger getId()
	{
		return id;
	}

	public Calendar getPersisted()
	{
		return persisted;
	}

	public Calendar getUpdated()
	{
		return updated;
	}

	public int getVersion()
	{
		return version;
	}

	public boolean hasId()
	{
		return AbstractEntity.isId(getId());
	}

	public boolean isDeleted()
	{
		return deleted;
	}

	protected void prePersist()
	{
		setPersisted(Calendar.getInstance());
	}

	protected void preUpdate()
	{
		setUpdated(Calendar.getInstance());
	}

	public void removePropertyChangeListener(final String propertyName, final PropertyChangeListener listener)
	{
		propertyChangeSupport.removePropertyChangeListener(listener);
	}

	public void setDeleted(final boolean deleted)
	{
		propertyChangeSupport.firePropertyChange("deleted", this.deleted, this.deleted = deleted);
	}

	public void setId(final BigInteger id)
	{
		propertyChangeSupport.firePropertyChange("id", this.id, this.id = id);
	}

	public void setPersisted(final Calendar persisted)
	{
		propertyChangeSupport.firePropertyChange("persisted", this.persisted, this.persisted = persisted);
	}

	public void setUpdated(final Calendar updated)
	{
		propertyChangeSupport.firePropertyChange("updated", this.updated, this.updated = updated);
	}

	protected void setVersion(final int version)
	{
		this.version = version;
	}

	protected String stringValueOf(final String value)
	{
		return value == null ? "" : value;
	}

	public void update(final E source)
	{
		setDeleted(source.isDeleted());
		// setId(source.getId());
		setPersisted(getPersisted());
		setUpdated(source.getUpdated());
		setVersion(source.getVersion());
	}
	
	public boolean equals(E other)
	{
		if (other.getClass().equals(this.getClass()))
		{
			if (other.getId() == null && this.getId() == null)
			{
				return other.hashCode() == this.hashCode();
			}
			else if (other.getId() != null && this.getId() != null)
			{
				return other.getId().equals(this.getId());
			}
		}
		return false;
	}

	public Agent getAgent()
	{
		return agent;
	}

	public void setAgent(Agent agent)
	{
		this.agent = agent;
	}
}


and last but not least my TectonicsLevel.class
package ch.eugster.herakles.persistence.model;

import java.util.List;
import java.util.Vector;

public class TectonicsLevel extends AbstractEntity<TectonicsLevel> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Tectonics tectonics;
	
	private final List<TectonicsLevelLink> parents = new Vector<TectonicsLevelLink>();

	private final List<TectonicsLevelLink> children = new Vector<TectonicsLevelLink>();

	private String description;

	private byte[] image;

	private String name;

	private TectonicsLevel() {
	}

	private TectonicsLevel(Tectonics tectonics)
	{
		this.tectonics = tectonics;
	}
	
	public void addChildLevel(final TectonicsLevelLink level) 
	{
		propertyChangeSupport.firePropertyChange("addChildLevel", children,
				children.add(level));
	}

	public void addParentLevel(final TectonicsLevelLink level) 
	{
		propertyChangeSupport.firePropertyChange("addParentLevel", parents,
				parents.add(level));
	}

	public List<TectonicsLevelLink> getChildLevels() 
	{
		return children;
	}

	public List<TectonicsLevelLink> getParentLevels() 
	{
		return parents;
	}

	public String getDescription() {
		return description;
	}

	public byte[] getImage() 
	{
		return image;
	}

	public String getName() {
		return name;
	}

	public void removeChildLevel(final TectonicsLevel level) 
	{
		propertyChangeSupport.firePropertyChange("removeChildLevel", children,
				children.remove(level));
	}

	public void removeParentLevel(final TectonicsLevel level) 
	{
		propertyChangeSupport.firePropertyChange("removeParentLevel", parents,
				parents.remove(level));
	}

	public void setDescription(final String description) {
		propertyChangeSupport.firePropertyChange("description",
				this.description, this.description = (description == null
						|| description.isEmpty() ? null : description));
	}

	public void setImage(final byte[] image) 
	{
		this.propertyChangeSupport.firePropertyChange("image", this.image, this.image = image);
	}

	public void setName(final String name) {
		propertyChangeSupport.firePropertyChange("name", this.name,
				this.name = (name == null || name.isEmpty() ? null : name));
	}

	@Override
	public void update(final TectonicsLevel source) {
		super.update(source);
		setName(source.getDescription());
		setDescription(source.getDescription());
		setImage(source.getImage());

//		final Collection<TectonicsLevel> sourceLevels = source
//				.getLevels();
//		for (final TectonicsLevel sourceLevel : sourceLevels) {
//			if (sourceLevel.getId() == null) {
//				final TectonicsLevel targetLevel = TectonicsLevel
//						.newInstance();
//				targetLevel.update(sourceLevel);
//				addLevel(targetLevel);
//			} else {
//				final Collection<TectonicsLevel> levels = getLevels();
//				for (final TectonicsLevel level : levels) {
//					if (level.getId().equals(sourceLevel.getId())) {
//						level.update(sourceLevel);
//					}
//				}
//			}
//		}
	}

	public static TectonicsLevel newInstance() 
	{
		return (TectonicsLevel) AbstractEntity
				.newInstance(new TectonicsLevel());
	}

	public static TectonicsLevel newInstance(Tectonics tectonics) 
	{
		return (TectonicsLevel) AbstractEntity
				.newInstance(new TectonicsLevel(tectonics));
	}

	public Tectonics getTectonics() {
		return tectonics;
	}

	public void setTectonics(Tectonics tectonics) 
	{
		propertyChangeSupport.firePropertyChange("tectonics", this.tectonics,
				this.tectonics = tectonics);
	}
}


The following tectonics.class is another class, but has the same configuration concerning my problem. eclipselink does not complain here, may be it stops directly after it has found the "error":

package ch.eugster.herakles.persistence.model;

import java.util.List;
import java.util.Vector;

public class TectonicsLevel extends AbstractEntity<TectonicsLevel> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Tectonics tectonics;
	
	private final List<TectonicsLevelLink> parents = new Vector<TectonicsLevelLink>();

	private final List<TectonicsLevelLink> children = new Vector<TectonicsLevelLink>();

	private String description;

	private byte[] image;

	private String name;

	private TectonicsLevel() {
	}

	private TectonicsLevel(Tectonics tectonics)
	{
		this.tectonics = tectonics;
	}
	
	public void addChildLevel(final TectonicsLevelLink level) 
	{
		propertyChangeSupport.firePropertyChange("addChildLevel", children,
				children.add(level));
	}

	public void addParentLevel(final TectonicsLevelLink level) 
	{
		propertyChangeSupport.firePropertyChange("addParentLevel", parents,
				parents.add(level));
	}

	public List<TectonicsLevelLink> getChildLevels() 
	{
		return children;
	}

	public List<TectonicsLevelLink> getParentLevels() 
	{
		return parents;
	}

	public String getDescription() {
		return description;
	}

	public byte[] getImage() 
	{
		return image;
	}

	public String getName() {
		return name;
	}

	public void removeChildLevel(final TectonicsLevel level) 
	{
		propertyChangeSupport.firePropertyChange("removeChildLevel", children,
				children.remove(level));
	}

	public void removeParentLevel(final TectonicsLevel level) 
	{
		propertyChangeSupport.firePropertyChange("removeParentLevel", parents,
				parents.remove(level));
	}

	public void setDescription(final String description) {
		propertyChangeSupport.firePropertyChange("description",
				this.description, this.description = (description == null
						|| description.isEmpty() ? null : description));
	}

	public void setImage(final byte[] image) 
	{
		this.propertyChangeSupport.firePropertyChange("image", this.image, this.image = image);
	}

	public void setName(final String name) {
		propertyChangeSupport.firePropertyChange("name", this.name,
				this.name = (name == null || name.isEmpty() ? null : name));
	}

	@Override
	public void update(final TectonicsLevel source) {
		super.update(source);
		setName(source.getDescription());
		setDescription(source.getDescription());
		setImage(source.getImage());

//		final Collection<TectonicsLevel> sourceLevels = source
//				.getLevels();
//		for (final TectonicsLevel sourceLevel : sourceLevels) {
//			if (sourceLevel.getId() == null) {
//				final TectonicsLevel targetLevel = TectonicsLevel
//						.newInstance();
//				targetLevel.update(sourceLevel);
//				addLevel(targetLevel);
//			} else {
//				final Collection<TectonicsLevel> levels = getLevels();
//				for (final TectonicsLevel level : levels) {
//					if (level.getId().equals(sourceLevel.getId())) {
//						level.update(sourceLevel);
//					}
//				}
//			}
//		}
	}

	public static TectonicsLevel newInstance() 
	{
		return (TectonicsLevel) AbstractEntity
				.newInstance(new TectonicsLevel());
	}

	public static TectonicsLevel newInstance(Tectonics tectonics) 
	{
		return (TectonicsLevel) AbstractEntity
				.newInstance(new TectonicsLevel(tectonics));
	}

	public Tectonics getTectonics() {
		return tectonics;
	}

	public void setTectonics(Tectonics tectonics) 
	{
		propertyChangeSupport.firePropertyChange("tectonics", this.tectonics,
				this.tectonics = tectonics);
	}
}
Re: @Id and @AttributeOverride [message #945741 is a reply to message #945661] Mon, 15 October 2012 11:42 Go to previous messageGo to next message
Eclipse UserFriend
I can't see anything wrong with your model. Any chance you could capture the logging and post it? Also looks like you posted TectonicsLevel level twice and not the Tectonics class.
Re: @Id and @AttributeOverride [message #945745 is a reply to message #945741] Mon, 15 October 2012 11:45 Go to previous messageGo to next message
Eclipse UserFriend
Here's the logging output:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [bundleresource://209.fwk1701693537:1/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://209.fwk1701693537:2/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://209.fwk1701693537:3/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://209.fwk1701693537:4/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
15.10.2012 17:34:53 org.apache.aries.jndi.startup.Activator start
INFO: It was not possible to register an InitialContextFactoryBuilder with the NamingManager because another builder called org.apache.aries.jndi.OSGiInitialContextFactoryBuilder was already registered. Support for calling new InitialContext() will not be enabled.
15.10.2012 17:34:53 org.apache.aries.jndi.startup.Activator start
INFO: It was not possible to register an ObjectFactoryBuilder with the NamingManager because another builder called org.apache.aries.jndi.OSGiInitialContextFactoryBuilder was already registered. Looking up certain objects may not work correctly.
15.10.2012 17:34:53 org.apache.aries.jpa.container.context.transaction.impl.JTAPersistenceContextRegistry addingService
INFO: A TransactionSynchronizationRegistry service is now available in the runtime. Managed persistence contexts will now integrate with JTA transactions using {javax.transaction.TransactionManager, javax.transaction.TransactionSynchronizationRegistry, javax.transaction.UserTransaction, org.apache.geronimo.transaction.manager.RecoverableTransactionManager}={service.id=45}.
15.10.2012 17:34:53 org.apache.aries.jpa.container.impl.PersistenceBundleManager initConfig
INFO: The file org.apache.aries.jpa.container.properties was not found in bundle org.apache.aries.jpa.container/1.0.0. The default properties {} will be used.
[EL Finest]: 2012-10-15 17:34:53.296--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--Begin predeploying Persistence Unit herakles; session bundleresource://261.fwk1701693537/_herakles; state Initial; factoryCount 0
[EL Finest]: 2012-10-15 17:34:53.306--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--property=eclipselink.orm.throw.exceptions; default value=true
[EL Finest]: 2012-10-15 17:34:53.306--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--property=eclipselink.multitenant.tenants-share-emf; default value=true
[EL Finest]: 2012-10-15 17:34:53.306--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--property=eclipselink.multitenant.tenants-share-cache; default value=false
[EL Finer]: 2012-10-15 17:34:53.318--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--Searching for default mapping file in bundleresource://261.fwk1701693537/ (There is no English translation for this message.)
[EL Finer]: 2012-10-15 17:34:53.322--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--Found a default mapping file at bundleresource://261.fwk1701693537/META-INF/orm.xml for root URL bundleresource://261.fwk1701693537/ (There is no English translation for this message.)
[EL Finer]: 2012-10-15 17:34:53.823--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--Searching for default mapping file in bundleresource://261.fwk1701693537/ (There is no English translation for this message.)
[EL Config]: 2012-10-15 17:34:53.853--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--The target entity (reference) class for the one to many mapping element [field children] is being defaulted to: class ch.eugster.herakles.persistence.model.TectonicsLevelLink.
[EL Config]: 2012-10-15 17:34:53.857--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--The element [field parents] is being defaulted to a one to many mapping.
[EL Config]: 2012-10-15 17:34:53.861--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--The target entity (reference) class for the one to many mapping element [field parents] is being defaulted to: class ch.eugster.herakles.persistence.model.TectonicsLevelLink.
[EL Config]: 2012-10-15 17:34:53.861--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--The element [field tectonics] is being defaulted to a one to one mapping.
[EL Config]: 2012-10-15 17:34:53.862--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--The target entity (reference) class for the one to one mapping element [field tectonics] is being defaulted to: class ch.eugster.herakles.persistence.model.Tectonics.
[EL Config]: 2012-10-15 17:34:53.863--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--The target entity (reference) class for the one to many mapping element [field levels] is being defaulted to: class ch.eugster.herakles.persistence.model.TectonicsLevel.
[EL Config]: 2012-10-15 17:34:53.863--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--The target entity (reference) class for the many to one mapping element [field agent] is being defaulted to: class ch.eugster.herakles.persistence.model.Agent.
[EL Config]: 2012-10-15 17:34:53.863--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--The target entity (reference) class for the many to one mapping element [field parent] is being defaulted to: class ch.eugster.herakles.persistence.model.TectonicsLevel.
[EL Config]: 2012-10-15 17:34:53.864--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--The target entity (reference) class for the one to one mapping element [field child] is being defaulted to: class ch.eugster.herakles.persistence.model.TectonicsLevel.
[EL Finest]: 2012-10-15 17:34:53.883--ServerSession(321891948)--Thread(Thread[Start Level Event Dispatcher,5,main])--End predeploying Persistence Unit herakles; session bundleresource://261.fwk1701693537/_herakles; state PredeployFailed; factoryCount 0
[EL Finest]: 2012-10-15 17:34:53.889--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.proxy_218 (There is no English translation for this message.)
!SESSION 2012-10-15 17:34:52.025 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_35
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=de_DE
Command-line arguments:  -dev file:/Users/ceugster/Projekte/Herakles-4.2/Workspace-4.2/.metadata/.plugins/org.eclipse.pde.core/OSGi Runtime/dev.properties -os macosx -ws cocoa -arch x86_64 -consoleLog -console

!ENTRY org.apache.aries.jpa.container 4 0 2012-10-15 17:34:53.891
!MESSAGE FrameworkEvent ERROR
[EL Finest]: 2012-10-15 17:34:53.892--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.jmx.blueprint.api_219 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:53.892--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.blueprint_220 (There is no English translation for this message.)
!STACK 0
org.osgi.framework.BundleException: Exception in org.apache.aries.jpa.container.impl.PersistenceBundleManager.start() of bundle org.apache.aries.jpa.container.
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
	at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [herakles] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class ch.eugster.herakles.persistence.model.TectonicsLevel] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1441)
	at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:208)
	at org.apache.aries.jpa.eclipselink.adapter.EclipseLinkProviderService$1.createContainerEntityManagerFactory(EclipseLinkProviderService.java:70)
	at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:329)
	at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:175)
	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.setupManager(PersistenceBundleManager.java:394)
	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.addingBundle(PersistenceBundleManager.java:154)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerAdding(BundleHookBundleTracker.java:185)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerAdding(BundleHookBundleTracker.java:128)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.trackAdding(BundleHookBundleTracker.java:492)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.trackInitial(BundleHookBundleTracker.java:374)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker.open(BundleHookBundleTracker.java:81)
	at org.apache.aries.util.tracker.RecursiveBundleTracker.open(RecursiveBundleTracker.java:92)
	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.open(PersistenceBundleManager.java:134)
	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.start(PersistenceBundleManager.java:624)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	... 12 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [herakles] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class ch.eugster.herakles.persistence.model.TectonicsLevel] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
	at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:221)
	... 30 more
Caused by: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class ch.eugster.herakles.persistence.model.TectonicsLevel] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
	at org.eclipse.persistence.exceptions.ValidationException.noPrimaryKeyAnnotationsFound(ValidationException.java:1392)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.validatePrimaryKey(EntityAccessor.java:1336)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processMappingAccessors(EntityAccessor.java:1067)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:631)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1685)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:532)
	at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:546)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1376)
	... 29 more
Root exception:
javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [herakles] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class ch.eugster.herakles.persistence.model.TectonicsLevel] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1441)
	at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:208)
	at org.apache.aries.jpa.eclipselink.adapter.EclipseLinkProviderService$1.createContainerEntityManagerFactory(EclipseLinkProviderService.java:70)
	at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:329)
	at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:175)
	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.setupManager(PersistenceBundleManager.java:394)
	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.addingBundle(PersistenceBundleManager.java:154)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerAdding(BundleHookBundleTracker.java:185)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerAdding(BundleHookBundleTracker.java:128)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.trackAdding(BundleHookBundleTracker.java:492)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.trackInitial(BundleHookBundleTracker.java:374)
	at org.apache.aries.util.tracker.hook.BundleHookBundleTracker.open(BundleHookBundleTracker.java:81)
	at org.apache.aries.util.tracker.RecursiveBundleTracker.open(RecursiveBundleTracker.java:92)
	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.open(PersistenceBundleManager.java:134)
	at org.apache.aries.jpa.container.impl.PersistenceBundleManager.start(PersistenceBundleManager.java:624)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
	at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [herakles] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class ch.eugster.herakles.persistence.model.TectonicsLevel] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
	at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:221)
	... 30 more
Caused by: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.4.0.v20120229-r10915): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class ch.eugster.herakles.persistence.model.TectonicsLevel] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
	at org.eclipse.persistence.exceptions.ValidationException.noPrimaryKeyAnnotationsFound(ValidationException.java:1392)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.validatePrimaryKey(EntityAccessor.java:1336)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processMappingAccessors(EntityAccessor.java:1067)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:631)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1685)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:532)
	at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:546)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1376)
	... 29 more
[EL Finest]: 2012-10-15 17:34:53.95--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.quiesce.manager_222 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:53.956--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.jmx.core_225 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:53.983--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.proxy.api_226 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:53.983--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.blueprint.core_227 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.068--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.blueprint.api_228 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.069--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.jpa.api_229 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.07--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.blueprint.cm_230 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.072--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.jmx.core.whiteboard_231 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.093--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.jmx.blueprint.core_232 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.097--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.aries.jndi.url_234 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.101--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.eclipse.osgi.services_243 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.102--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.eclipse.equinox.preferences_244 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.133--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.felix.gogo.command_245 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.14--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.eclipse.equinox.console_247 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.152--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.felix.gogo.runtime_249 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.164--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.apache.felix.gogo.shell_248 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.175--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: org.eclipse.equinox.util_250 (There is no English translation for this message.)
[EL Finest]: 2012-10-15 17:34:54.182--Thread(Thread[Start Level Event Dispatcher,5,main])--EclipseLink OSGi - examining bundle: ch.eugster.herakles.persistence_261 (There is no English translation for this message.)
15.10.2012 17:34:54 org.apache.aries.blueprint.container.BlueprintContainerImpl doRun
INFO: Bundle ch.eugster.herakles.persistence is waiting for namespace handlers [http://aries.apache.org/xmlns/transactions/v1.0.0, http://aries.apache.org/xmlns/jpa/v1.1.0]

!ENTRY org.eclipse.osgi 4 0 2012-10-15 17:34:54.190
!MESSAGE Bundle org.apache.aries.jpa.container_1.0.0 [217] is not active.
15.10.2012 17:34:54 org.apache.aries.blueprint.container.BlueprintContainerImpl doRun
INFO: Bundle ch.eugster.herakles.persistence is waiting for dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=herakles))(objectClass=javax.persistence.EntityManagerFactory))]
osgi> 15.10.2012 17:39:54 org.apache.aries.blueprint.container.BlueprintContainerImpl$1 run
SCHWERWIEGEND: Unable to start blueprint container for bundle ch.eugster.herakles.persistence due to unresolved dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=herakles))(objectClass=javax.persistence.EntityManagerFactory))]
java.util.concurrent.TimeoutException
	at org.apache.aries.blueprint.container.BlueprintContainerImpl$1.run(BlueprintContainerImpl.java:302)
	at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:680)


And sorry about the second posting of TectonicsLevel. I post the Tectonics.class now
package ch.eugster.herakles.persistence.model;

import java.util.List;
import java.util.Vector;

public class Tectonics extends AbstractEntity<Tectonics> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private final List<TectonicsLevel> levels = new Vector<TectonicsLevel>();

	private String description;

	private byte[] image;

	private String name;

	private Tectonics() {
	}

	public void addLevel(final TectonicsLevel level) {
		propertyChangeSupport.firePropertyChange("addLevel", levels,
				levels.add(level));
	}

	public void removeLevel(final TectonicsLevel level) {
		propertyChangeSupport.firePropertyChange("removeLevel", levels,
				levels.remove(level));
	}

	public List<TectonicsLevel> getLevels() {
		return levels;
	}

	public String getDescription() {
		return description;
	}

	public byte[] getImage() {
//		Image image = null;
//		try {
//			if (this.image != null) {
//				final InputStream in = new ByteArrayInputStream(this.image);
//				final ImageData imageData = new ImageData(in);
//				image = new Image(Display.getCurrent(), imageData);
//			}
//		} catch (final Exception e) {
//			e.printStackTrace();
//		}
		return image;
	}

	public String getName() {
		return name;
	}

//	public void removeLevel(final TectonicsLevel level) {
//		propertyChangeSupport.firePropertyChange("removeLevel", levels,
//				levels.remove(level));
//	}

	public void setDescription(final String description) {
		propertyChangeSupport.firePropertyChange("description",
				this.description, this.description = (description == null
						|| description.isEmpty() ? null : description));
	}

	public void setImage(final byte[] image) {
//		final Image oldImage = this.getImage();
//		if (image == null) {
//			this.image = null;
//		} else {
//			try {
//				final ByteArrayOutputStream out = new ByteArrayOutputStream(
//						1024);
//				final ImageLoader imageLoader = new ImageLoader();
//				imageLoader.data = new ImageData[] { image.getImageData() };
//				imageLoader.save(out, SWT.IMAGE_PNG);
//				this.image = out.toByteArray();
//			} catch (final Exception e) {
//				e.printStackTrace();
//			}
//		}
//		this.propertyChangeSupport.firePropertyChange("image", oldImage, image);
//		if (oldImage != null) {
//			oldImage.dispose();
//		}
	}

	public void setName(final String name) {
		propertyChangeSupport.firePropertyChange("name", this.name,
				this.name = (name == null || name.isEmpty() ? null : name));
	}

	@Override
	public void update(final Tectonics source) {
		super.update(source);
		setName(source.getDescription());
		setDescription(source.getDescription());
		setImage(source.getImage());

//		final Collection<TectonicsLevel> sourceLevels = source
//				.getLevels();
//		for (final TectonicsLevel sourceLevel : sourceLevels) {
//			if (sourceLevel.getId() == null) {
//				final TectonicsLevel targetLevel = TectonicsLevel
//						.newInstance();
//				targetLevel.update(sourceLevel);
//				addLevel(targetLevel);
//			} else {
//				final Collection<TectonicsLevel> levels = getLevels();
//				for (final TectonicsLevel level : levels) {
//					if (level.getId().equals(sourceLevel.getId())) {
//						level.update(sourceLevel);
//					}
//				}
//			}
//		}
	}

	public static Tectonics newInstance() {
		return (Tectonics) AbstractEntity
				.newInstance(new Tectonics());
	}
}
Re: @Id and @AttributeOverride [message #945907 is a reply to message #945745] Mon, 15 October 2012 15:29 Go to previous messageGo to next message
Eclipse UserFriend
Seems very strange (in that it should work, I see no issues). For sake of testing,
any chance you could try mapping AbstactEntity with an @Id annotation instead (and comment out the mapping from XML)?

Re: @Id and @AttributeOverride [message #945926 is a reply to message #945907] Mon, 15 October 2012 15:59 Go to previous messageGo to next message
Eclipse UserFriend
I changed the classes as you proposed, there is still the same exception. Is it possible, that overriding the attribute @Id is not allowed? In

http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Entities/MappedSuperclass

there is said:
Quote:
You can use the @AttributeOverride and @AttributeOverrides annotations, or <attribute-override> XML element to override the column for a basic attribute in a mapped superclass. This allows for the column name to be different in each subclass.


Nothing is said about the id attribute can be overridden whereas in

http://www.objectdb.com/api/java/jpa/AttributeOverride

they write that (AttributeOverride is):

Quote:

Used to override the mapping of a Basic (whether explicit or default) property or field or Id property or field.


Strange in any case...
Re: @Id and @AttributeOverride [message #946722 is a reply to message #945926] Tue, 16 October 2012 08:46 Go to previous messageGo to next message
Eclipse UserFriend
An attribute override is absolutely allowed for an Id mapping, in fact I just tested it myself. Regardless, the fact that the @Id annotation itself is not
found indicates that there is another underlying issues, namely that the mapped superclass is not being found/processed for some reason. Can you elaborate
on your setup a little further? The logging seems to be very reduced as well. With FINEST set in your persistence.xml we should see a lot more output.

Would seem that perhaps you are loading a different persistence.xml and/or orm.xml?
Re: @Id and @AttributeOverride (SOLVED) [message #946756 is a reply to message #946722] Tue, 16 October 2012 09:22 Go to previous message
Eclipse UserFriend
Hi Guy,

I have only one persistence.xml in my whole workspace and there I have set FINEST already. Maybe there is another place where I can extend the logging?

Wait, wait! I got it! The package name of the class AbstractEntity was false! Oh my! Sorry about that! And thank you!

[Updated on: Tue, 16 October 2012 09:22] by Moderator

Previous Topic:ArrayIndexOutOfBounds during commit
Next Topic:Is the use of @Column annotation as substitute of hibernate @Formula is possible?
Goto Forum:
  


Current Time: Tue Jul 22 19:30:37 EDT 2025

Powered by FUDForum. Page generated in 0.06049 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top