Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » please help, errors with Map <Entity, Basic>
please help, errors with Map <Entity, Basic> [message #882327] Wed, 06 June 2012 09:04 Go to next message
Luisa Rossi is currently offline Luisa Rossi
Messages: 5
Registered: June 2012
Junior Member
Please help,
In my bean I have attribute as:

private Map <Skill, Date> skills;

I am using orm.xml instead of annotations and have this chunk of configuration:

<element-collection name="skills">
<map-key-join-column name="ID_SKILL" />
<column name="ACQUIRED_ON" />
<temporal>DATE</temporal>
<collection-table name="ACQUIRED_SKILL">
<join-column name="ID_EMPLOYEE" />
</collection-table>
</element-collection>

in my db tables are like this:

create table EMPLOYEE (
ID_EMPLOYEE numeric (12) not null,
DESCRIPTION varchar(500) null
);
alter table EMPLOYEE add primary key (ID_EMPLOYEE);

create table SKILL (
ID_SKILL numeric (12) not null,
DESCRIPTION varchar(500) null
);
alter table SKILL add primary key (ID_SKILL);

create table ACQUIRED_SKILL (
ID_SKILL numeric (12) not null,
ID_EMPLOYEE numeric (12) not null,
ACQUIRED_ON date null
);
alter table ACQUIRED_SKILL add primary key (ID_SKILL,ID_EMPLOYEE);
alter table ACQUIRED_SKILL add foreign key (ID_SKILL) references SKILL (ID_SKILL);
alter table ACQUIRED_SKILL add foreign key (ID_EMPLOYEE) references EMPLOYEE (ID_EMPLOYEE);

when I put a 'transient' on the attribute of my bean everything apart of this mapping works, probably because it's ignored, otherwise i get exceptions:

[EL Config]: metadata: 2012-06-06 10:39:24.821--ServerSession(8906500)--Thread(Thread[main,5,main])--The primary key column name for the mapping element [field skills] is being defaulted to: ID_EMPLOYEE.
[EL Config]: metadata: 2012-06-06 10:39:24.821--ServerSession(8906500)--Thread(Thread[main,5,main])--The primary key column name for the mapping element [field skills] is being defaulted to: ID_SKILL.
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.0.v20120604-r11619): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@35ce36
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120604-r11619): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [sara-beans] failed.
Internal Exception: java.lang.NullPointerException

P.S. eclipse 3.7sr2, java 1.6.0.31

Thanks
Re: please help, errors with Map <Entity, Basic> [message #882466 is a reply to message #882327] Wed, 06 June 2012 14:05 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1031
Registered: July 2009
Senior Member
Can you post the full stack trace? Does it work if you use annotations? How about if you use an java.sql.Date object and remove the temporal tag?

Best Regards,
Chris
Re: please help, errors with Map <Entity, Basic> [message #882511 is a reply to message #882466] Wed, 06 June 2012 15:55 Go to previous messageGo to next message
Luisa Rossi is currently offline Luisa Rossi
Messages: 5
Registered: June 2012
Junior Member
Hi Chris,
java.sql.Date without temporal gave the same exceptions, regarding the annotations I have to use the xml, but I briefly tried with those and it gave me the same result... If you want I can extract this in smallish maven project...
Re: please help, errors with Map <Entity, Basic> [message #882992 is a reply to message #882511] Thu, 07 June 2012 15:48 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1031
Registered: July 2009
Senior Member
EclipseLink's automated testing includes the following mapping:
@ElementCollection
@CollectionTable(name = "ADV_SIMPLE_ENTITY_LANGUAGE", joinColumns = @JoinColumn(name = "SIMPLE_ID"))
@MapKeyJoinColumn(name = "LANG_CODE", referencedColumnName = "CODE")
@Column(name = "LANG_DESCRIPTION")
private Map<SimpleLanguage, String> simpleLanguage

So I'm not sure what is different from yours other than using a Date instead of String. Can you please post the exception for now, as I may be able to tell what might be going wrong if it can show what might be null in the code.

Regards,
Chris
Re: please help, errors with Map <Entity, Basic> [message #883294 is a reply to message #882992] Fri, 08 June 2012 08:21 Go to previous messageGo to next message
Luisa Rossi is currently offline Luisa Rossi
Messages: 5
Registered: June 2012
Junior Member
Hi Chris,
Maybe it's nothing but I am using a .xml instead of annotations anyway here is my stacktrace, hope it helps:

Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.0.v20120604-r11619): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@35ce36
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120604-r11619): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [ski] failed.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:115)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at it.esempio.jpa.JPAStarter.main(JPAStarter.java:61)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120604-r11619): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [ski] failed.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1541)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1532)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:105)
... 2 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120604-r11619): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [ski] failed.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:221)
... 6 more
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.metadata.ORMetadata.setFieldName(ORMetadata.java:715)
at org.eclipse.persistence.internal.jpa.metadata.columns.MetadataColumn.getDatabaseField(MetadataColumn.java:109)
at org.eclipse.persistence.internal.jpa.metadata.columns.RelationalColumnMetadata.getForeignKeyField(RelationalColumnMetadata.java:86)
at org.eclipse.persistence.internal.jpa.metadata.columns.JoinColumnMetadata.getForeignKeyField(JoinColumnMetadata.java:118)
at org.eclipse.persistence.internal.jpa.metadata.columns.RelationalColumnMetadata.getForeignKeyField(RelationalColumnMetadata.java:97)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processForeignKeyRelationship(MappingAccessor.java:1696)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processEntityMapKeyClass(MappingAccessor.java:1536)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processMapKeyClass(MappingAccessor.java:1608)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processContainerPolicyAndIndirection(MappingAccessor.java:1419)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.DirectCollectionAccessor.processDirectMapMapping(DirectCollectionAccessor.java:472)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ElementCollectionAccessor.process(ElementCollectionAccessor.java:774)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processDirectCollectionAccessors(MetadataProject.java:1445)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1718)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:535)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:550)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1469)
... 4 more
Re: please help, errors with Map <Entity, Basic> [message #883564 is a reply to message #883294] Fri, 08 June 2012 20:02 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1031
Registered: July 2009
Senior Member
The difference from EclipseLink test and your xml mapping is that they define the referenced-column-name while yours relies on the default.

Try changing it to
<map-key-join-column name="ID_SKILL" referenced-column-name="ID_SKILL"/>

If that resolves the issue please file a bug including the stack stack trace and the example mapping.

Best Regards,
Chris
Re: please help, errors with Map <Entity, Basic> [message #885090 is a reply to message #883564] Tue, 12 June 2012 12:58 Go to previous messageGo to next message
Luisa Rossi is currently offline Luisa Rossi
Messages: 5
Registered: June 2012
Junior Member
Hi Chris,
Unfortunately your 'referenced-column' suggestion doesn't help, error message is the same. In the meantime I prepared a small 'helloworld' project to demo this. If you or somebody else can take a look I would be gratefull.
The culprit is the Employee class more precisely 'skills' attribute, when it is marked as 'transient' it gets ignored and everything works, whan I remove transient: kaboom...
Thanks
Re: please help, errors with Map <Entity, Basic> [message #888708 is a reply to message #885090] Mon, 18 June 2012 14:18 Go to previous message
Luisa Rossi is currently offline Luisa Rossi
Messages: 5
Registered: June 2012
Junior Member
Please, could some more experienced than me take look at this ? It is pretty trivial example but I cannot see any error on my side...
Here you will find further updated alleged example with changes to be decoupled from eclipselink, as in the meantime I tried with other frameowrks (openjpa, hibernate, as you will find them commented-out inside pom.xml)
Please, probably is something trivial, but I am blind...
Previous Topic:Entity lazy loading strategy from remote client
Next Topic:EclipseLink can't login on startup project in Eclipse [solved]
Goto Forum:
  


Current Time: Mon Oct 20 09:57:33 GMT 2014

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

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