Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink 2 ignoring my annotations!(I am trying to use annotation and mappings.xml but it seems to ignore my annotations when i have a mappings.xml file.)
EclipseLink 2 ignoring my annotations! [message #526164] Fri, 09 April 2010 04:21 Go to next message
Praveen  is currently offline Praveen Friend
Messages: 2
Registered: April 2010
Junior Member
My entity class defines all the annotations for persistence and I am running Websphere 7 with EclipseLink 2. This all works fine.

I also want to use mapping.xml file to define a listener for some entities so that i can - say marshal them and send it to a mesg queue or something.

When i enable an entity definition, i start to get SQL Exceptions essentially it looks like eclipse link is trying to resolve the column name by using the field name rather than column name defined by the annotations which are different.

This set up works fine with Toplink and GF v2.

My persistence.xml looks like this:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
  
  <persistence-unit name ="someUnit" transaction-type="JTA">
    <description>Some Application</description>
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

    <jta-data-source>jdbc/SomeDS</jta-data-source>
    <mapping-file>META-INF/mapping.xml</mapping-file>

    <jar-file>MyJar1.jar</jar-file>
    <jar-file>MyJar2.jar</jar-file>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
 
    <properties>
      <!-- generation values: none, create-tables, drop-and-create-tables -->
      <!-- output-mode value: database, sql-script -->
      <property name="eclipselink.ddl-generation" value="create-tables"/>
      <property name="eclipselink.ddl-generation.output-mode" value="sql-script"/>

      <property name="eclipselink.create-ddl-jdbc-file-name" value="create_ora.sql"/>
      <property name="eclipselink.drop-ddl-jdbc-file-name" value="drop_ora.sql"/> 

      <property name="eclipselink.target-database" 
                value="org.eclipse.persistence.platform.database.oracle.Oracle11Platform"/>

      <property name="eclipselink.target-server" 
                value="org.eclipse.persistence.platform.server.was.WebSphere_6_1_Platform"/>

      <property name="eclipselink.logging.level" value="INFO"/>
    </properties>
  </persistence-unit>
  
</persistence>


My mapping.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="1.0"
  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">
  
  <entity class="com.entity.person.Name" access="PROPERTY" metadata-complete="false">
    <entity-listeners>
      <entity-listener class="com.entity.auditing.listeners.AuditListener">
        <post-persist method-name="persist"/>
        <post-remove method-name="remove"/>
        <post-update method-name="update"/> 
      </entity-listener>
    </entity-listeners>
  </entity>

</entity-mappings>


Originally i did not have the following attribute but i tried to specify it as well but same results.

metadata-complete="false"


My Entity class :
@Entity
@Table(name = "NAME") //$NON-NLS-1$
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class Name extends EntityObject {

  private static final long serialVersionUID = 1L;
  
  @Column(name = "LAST")
  private String last = ""; //$NON-NLS-1$
  
  @Column(name = "FIRST")
  private String first = ""; //$NON-NLS-1$
  
  @Column(name = "MIDDLE")
  private String middle = ""; //$NON-NLS-1$
  
  @Column(name = "TITLE")
  private String title = ""; //$NON-NLS-1$

  @Column(name = "SUFFIX")
  private String suffix = ""; //$NON-NLS-1$

  @Column(name = "SOUNDEX_LAST")
  private String soundexLast = ""; //$NON-NLS-1$
......
// all the getter/setters here..

}



Here is the exception i am getting:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20090821-r4934): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00904: "SOUNDEXLAST": invalid identifier

Error Code: 904
Call: SELECT UUID, AUDIT_USER_ID, AUDIT_DATE, UPPERFIRST, OPT_LOCK, SOUNDEXFIRST, FIRST, ALIAS, SUFFIX, ORGANIZATION, MIDDLE, LAST, SOUNDEXMIDDLE, UPPERMIDDLE, UPPERLAST, TITLE, SOUNDEXLAST FROM NAME WHERE (UUID = ?)
	bind => [20266]
Query: ReadObjectQuery(name="name" referenceClass=Name )
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:332)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:674)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:517)
	at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:529)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:205)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:191)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectOneRow(DatasourceCallQueryMechanism.java:619)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectOneRowFromTable(ExpressionQueryMechanism.java:2564)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectOneRow(ExpressionQueryMechanism.java:2535)
	at org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:431)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:997)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:670)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)
	at org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:399)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2291)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1208)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1190)
	at org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.valueFromQuery(NoIndirectionPolicy.java:299)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRowInternal(ForeignReferenceMapping.java:1590)
	at org.eclipse.persistence.mappings.OneToOneMapping.valueFromRowInternal(OneToOneMapping.java:1518)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:1500)
	at org.eclipse.persistence.mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:1219)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:329)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:658)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:491)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:441)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:635)
	at org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:441)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:997)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:670)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)
	at org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:399)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2291)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1208)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1190)
	at org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.valueFromQuery(NoIndirectionPolicy.java:299)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRowInternal(ForeignReferenceMapping.java:1590)
	at org.eclipse.persistence.mappings.OneToOneMapping.valueFromRowInternal(OneToOneMapping.java:1518)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:1500)
	at org.eclipse.persistence.mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:1219)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:329)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:658)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:491)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectsInto(ObjectBuilder.java:844)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:467)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:997)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:670)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:432)
	at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2291)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1208)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1190)
	at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:85)
	at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:75)
	at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
	at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:161)
	at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:230)
	at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
	at org.eclipse.persistence.indirection.IndirectList.buildDelegate(IndirectList.java:237)
	at org.eclipse.persistence.indirection.IndirectList.getDelegate(IndirectList.java:397)
	at org.eclipse.persistence.indirection.IndirectList$1.<init>(IndirectList.java:525)
	at org.eclipse.persistence.indirection.IndirectList.listIterator(IndirectList.java:524)
	at org.eclipse.persistence.indirection.IndirectList.iterator(IndirectList.java:488)
	at acs.fw.middle.ejb.common.EntityHandlerBean.getPart(EntityHandlerBean.java:87)
	at acs.fw.middle.ejb.common.EJSLocal0SLEntityHandlerBean_c738f60e.getPart(EJSLocal0SLEntityHandlerBean_c738f60e.java)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
	at java.lang.reflect.Method.invoke(Method.java:599)
	at acs.middle.ejb.security.SecureGatewayHandlerBean.invokeMethodImpl(SecureGatewayHandlerBean.java:1062)
	at acs.middle.ejb.security.SecureGatewayHandlerBean.secureGetterImpl(SecureGatewayHandlerBean.java:261)
	at acs.middle.ejb.security.SecureGatewayHandlerBean.secureGetter(SecureGatewayHandlerBean.java:230)
	at acs.middle.ejb.security.EJSRemote0SLSecureGatewayHandlerBean_8d426f79.secureGetter(EJSRemote0SLSecureGatewayHandlerBean_8d426f79.java)
	at acs.middle.ejb.security._EJSRemote0SLSecureGatewayHandlerBean_8d426f79_Tie.secureGetter(_EJSRemote0SLSecureGatewayHandlerBean_8d426f79_Tie.java)
	at acs.middle.ejb.security._EJSRemote0SLSecureGatewayHandlerBean_8d426f79_Tie._invoke(_EJSRemote0SLSecureGatewayHandlerBean_8d426f79_Tie.java)
	at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:622)
	at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:475)
	at com.ibm.rmi.iiop.ORB.process(ORB.java:504)
	at com.ibm.CORBA.iiop.ORB.process(ORB.java:1571)
	at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2771)
	at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2640)
	at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:63)
	at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "SOUNDEXLAST": invalid identifier

	at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
	at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
	at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
	at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
	at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
	at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431)
	at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
	at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteQuery(WSJdbcPreparedStatement.java:1086)
	at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:707)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:876)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:589)
	... 82 more


Notice how it is trying to map soundexLast property to SOUNDEXLAST where as my column name is SOUNDEX_LAST.

[Updated on: Fri, 09 April 2010 04:23]

Report message to a moderator

Re: EclipseLink 2 ignoring my annotations! [message #526321 is a reply to message #526164] Fri, 09 April 2010 16:19 Go to previous message
Karen Butzke is currently offline Karen ButzkeFriend
Messages: 220
Registered: July 2009
Senior Member
The problem is because in the java you have the annotations listed on the fields, so the access type there is FIELD. In the mapping.xml file you have explicitly set the access type to PROPERTY. This means that it is looking for annotations on the java getter methods. If you remove that access type setting in the mapping.xml file it will default to FIELD because of the java annotation placement.

Karen
Previous Topic:Insert row with @SequenceGenerator ID fails
Next Topic:Weaving now static, reason for concern?
Goto Forum:
  


Current Time: Thu Dec 18 12:30:59 GMT 2014

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

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