Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Problem with using xml and annatations

Hi Lukasz,

You could have your entities extends a MappedSuperclass and define a caching strategy there to be applied to all its subclasses.

Cheers,
Guy

On 23/12/2013 8:54 AM, Lukasz Lichota wrote:
wow, thanks! I've been starring at the exception for too long ...
by the way, is there an easier way to specify global expiry time than to add such configuration for each entity?

best regards
Lukasz


On 23 December 2013 14:40, Christopher Delahunt <christopher.delahunt@xxxxxxxxxx> wrote:
There is a mistake in the XML file listing the address class.  The XML uses a class called Addresss, which is different then the actual Address class.  Fix the spelling mistake and it should work.

Best regards, 
Chris



On 2013-12-23, at 3:46 AM, Lukasz Lichota <lukasz.lichota@xxxxxxxxx> wrote:

hi,

I use annotations for my entities but would like to configure eclipselink caching expiry in xml so the entities can be reused with different cache settings.

But when I add eclipselink-orm.xml with this additional configuration I got "Entity name must be unique in a persistence unit." I tried various settings but it looks like I cannot force eclipselink to merge xml stuff with annotations (I have metadata-complete="false").

Can you offer any hint? (I tried versions from 2.3 to 2.5.1 but it behaves similarly) 

best regards
Lukasz

Here's the configuration:

<?xml version="1.0" encoding="UTF-8"?>
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             version="2.0">
    <persistence-unit name="rcPersisterTest" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <mapping-file>META-INF/eclipselink-orm.xml</mapping-file>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <shared-cache-mode>DISABLE_SELECTIVE</shared-cache-mode>
        <properties>
      <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
   <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:rcdb;sql.syntax_ora=true;ifexists=true"/>
   <property name="javax.persistence.jdbc.user" value="sa"/>
   <property name="javax.persistence.jdbc.password" value=""/>
   
   <property name="eclipselink.ddl-generation" value="create-tables"/>
   <property name="eclipselink.create-ddl-jdbc-file-name" value="createDDL_ddlGeneration.jdbc"/>
   <property name="eclipselink.ddl-generation.output-mode" value="both"/>

            <property name="eclipselink.logging.level" value="CONFIG"/>
            <property name="eclipselink.logging.level" value="FINEST"/>
            <property name="eclipselink.logging.logger" value="JavaLogger"/>
            <property name="eclipselink.logging.parameters" value="true"/>  
           
        </properties>
    </persistence-unit> 
</persistence>

eclipselink-orm.xml:

<?xml version="1.0"?>
<entity-mappings
version="2.1">

<entity name="Address" class="***.Addresss"
metadata-complete="false" >
<cache>
<expiry>1000</expiry>
</cache>
</entity>
  <entity name="Contact" class="***.Contact"
access="FIELD" metadata-complete="false" >
<cache>
<expiry>1000</expiry>
</cache>
</entity> 
</entity-mappings>

Address.java:

@Entity
@Table(...)
public class Address {
.,,

The exception:

Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@3326b249
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [rcPersisterTest] failed.
Internal Exception: Exception [EclipseLink-7237] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity name must be unique in a persistence unit. Entity name [Address] is used for the entity classes [****.entity.Address] and [****.entity.Addresss].
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
...
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [rcPersisterTest] failed.
Internal Exception: Exception [EclipseLink-7237] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity name must be unique in a persistence unit. Entity name [Address] is used for the entity classes [****.entity.Address] and [****.entity.Addresss].
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1954)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1945)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:96)
... 26 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [rcPersisterTest] failed.
Internal Exception: Exception [EclipseLink-7237] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity name must be unique in a persistence unit. Entity name [Address] is used for the entity classes [****.entity.Address] and [****.entity.Addresss].
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:230)
... 30 more
Caused by: Exception [EclipseLink-7237] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity name must be unique in a persistence unit. Entity name [Address] is used for the entity classes [****.entity.Address] and [****.entity.Addresss].
at org.eclipse.persistence.exceptions.ValidationException.nonUniqueEntityName(ValidationException.java:1386)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.addAlias(MetadataProject.java:431)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processEntity(EntityAccessor.java:1064)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:670)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1793)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:576)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:585)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1869)
... 28 more


Notice:  This email is confidential and may contain copyright material of Ocado Limited (the "Company"). Opinions and views expressed in this message may not necessarily reflect the opinions and views of the Company.

If you are not the intended recipient, please notify us immediately and delete all copies of this message. Please note that it is your responsibility to scan this message for viruses.

Company reg. no. 3875000.

Ocado Limited
Titan Court
3 Bishops Square
Hatfield Business Park
Hatfield
Herts
AL10 9NE
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users




--
Lukasz Lichota | Senior Software Developer | Ocado Technology Poland | Employee Management Systems


Notice:  This email is confidential and may contain copyright material of Ocado Limited (the "Company"). Opinions and views expressed in this message may not necessarily reflect the opinions and views of the Company.

If you are not the intended recipient, please notify us immediately and delete all copies of this message. Please note that it is your responsibility to scan this message for viruses.

Company reg. no. 3875000.

Ocado Limited
Titan Court
3 Bishops Square
Hatfield Business Park
Hatfield
Herts
AL10 9NE


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top