Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Eclipselink is attempting to convert fields it's not supposed to
Eclipselink is attempting to convert fields it's not supposed to [message #1715193] Fri, 20 November 2015 05:30 Go to next message
David Wheeler is currently offline David WheelerFriend
Messages: 6
Registered: November 2015
Junior Member
Hi,

We've recently upgraded from glassfish 3.1.2.2 (eclipselink 2.3.2) to glassfish 4.1.1 (eclipselink 2.6.1), and since then we've seen intermittent issues with the old converters that used to work.

In particular we see errors like this

Caused by: Exception [EclipseLink-3002] (Eclipse Persistence Services - 2.6.1.qualifier): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [2142420849], of class [class java.lang.String], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[usn-->smartedition.newsagentsubscriberqueue.usn]] with descriptor [RelationalDescriptor(com.inomial.newsagent.entities.NewsagentSubscriberQueue --> [DatabaseTable(smartedition.newsagentsubscriberqueue)])], could not be converted to [class java.util.UUID].


The thing that is odd is that the field in question NewsagentSubscriberQueue.usn is not annotated with @Convert at all (but the @Id field is).

@Entity
@Table(name="newsagentsubscriberqueue", schema="smartedition")
public class NewsagentSubscriberQueue implements Serializable
{
  <...>
  @Id
  @Converter(converterClass=UUIDConverter.class, name="newsagentSubscriberQueue_uuid")
  @Convert("newsagentSubscriberQueue_uuid")
  @Column(name="newsagentsubscriberqueue")
  private UUID newsagentSubscriberQueue = UUID.randomUUID();
  
  private String usn;
  <... other fields ...>
}


Is there something we could be doing to cause this, or is this just a bug?
Re: Eclipselink is attempting to convert fields it's not supposed to [message #1715889 is a reply to message #1715193] Fri, 27 November 2015 10:45 Go to previous messageGo to next message
Tomas Kraus is currently offline Tomas KrausFriend
Messages: 9
Registered: November 2014
Junior Member
GlassFish 4.1.1 is known to have some issues with EclipseLink. They used EclipseLink 2.6.1-RC1 which was not final 2.6.1 release and we know that there are some integration problems.
On the other hand this issue looks quite strange.
Can you try GlassFish 4.1 and test this scenario with it? I know it's older but I would believe that this one may work better with EclipseLink.

Re: Eclipselink is attempting to convert fields it's not supposed to [message #1715971 is a reply to message #1715889] Mon, 30 November 2015 00:32 Go to previous messageGo to next message
David Wheeler is currently offline David WheelerFriend
Messages: 6
Registered: November 2015
Junior Member
Thanks for the suggestion. We've tried glassfish 4.1 also, and it has the same trouble (plus some others!).

The strangest part is that it's not entirely reproducible - sometimes it works ok.

I'll see if we can get a test case together.
Re: Eclipselink is attempting to convert fields it's not supposed to [message #1719081 is a reply to message #1715971] Tue, 05 January 2016 01:08 Go to previous messageGo to next message
David Wheeler is currently offline David WheelerFriend
Messages: 6
Registered: November 2015
Junior Member
I've attempted to make a reproduction case, but I can't reproduce it outside of our main product, so presumably there's interference from something else, or else the reproduction case is too simple. I'm happy to try any suggestions to get the reproduction case to reproduce it.

One potential oddity to point out is that we're not using the @Id field (which is a UUID) to link the two entities, we're using a different candidate key (usn), which is the one that is triggering the problem.

Any help would be appreciated

Entity code snippits:


@Entity
@Table(name="newsagentsubscriberqueue", schema="smartedition")
@NamedQueries({
  @NamedQuery(name="NewsagentSubscriberQueue.getUnprocessedSubscribersByUsn", query="Select n from NewsagentSubscriberQueue n where n.processed is null and n.usn = :usn")
})
public class NewsagentSubscriberQueue implements Serializable
{
  [...]
  
  @Id
  @Converter(converterClass=UUIDConverter.class, name="newsagentSubscriberQueue_uuid")
  @Convert("newsagentSubscriberQueue_uuid")
  @Column(name="newsagentsubscriberqueue")
  private UUID newsagentSubscriberQueue = UUID.randomUUID();
  
  private String usn;
  
  [more basic fields ...]
  
  @ManyToOne
  @JoinColumn(name="usn", referencedColumnName="usn", insertable=false, updatable=false)
  private NewsagentSubscriberState subscriberState;

  [getters & setters...]
}

@Entity
@Table(name="newsagentsubscriberstate", schema="smartedition")
public class NewsagentSubscriberState implements Serializable
{
  @Id
  @Converter(converterClass=UUIDConverter.class, name="newsagentsubscriberstate_uuid")
  @Convert("newsagentsubscriberstate_uuid")
  @Column(name="newsagentsubscriberstate")
  private UUID newsagentSubscriberState = UUID.randomUUID();
  
  private String usn;
  
  [...]
  
  @OneToMany (mappedBy="subscriberState", orphanRemoval=true)
  private Set<NewsagentSubscriberQueue> newsagentSubscriberQueue;
  [getters & setters...]
}



Local Exception Stack: 
Exception [EclipseLink-3002] (Eclipse Persistence Services - 2.6.1.qualifier): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [2142420823], of class [class java.lang.String], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[usn-->smartedition.newsagentsubscriberqueue.usn]] with descriptor [RelationalDescriptor(com.inomial.newsagent.entities.NewsagentSubscriberQueue --> [DatabaseTable(smartedition.newsagentsubscriberqueue)])], could not be converted to [class java.util.UUID].
	at org.eclipse.persistence.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:78)
	at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:176)
	at org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.convertObject(DatasourcePlatform.java:179)
	at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.getFieldValue(AbstractDirectMapping.java:789)
	at org.eclipse.persistence.internal.expressions.QueryKeyExpression.getFieldValue(QueryKeyExpression.java:420)
	at org.eclipse.persistence.internal.expressions.ParameterExpression.getValue(ParameterExpression.java:299)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.translate(DatabaseCall.java:1102)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:241)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:299)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:694)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2740)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2693)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:559)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1175)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:904)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1134)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:460)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1222)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1857)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1839)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
	at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
	at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:473)
	at com.inomial.newsagent.listener.NewsagentProvisionManagerBean.deleteFromSubscriberQueue(NewsagentProvisionManagerBean.java:267)


Triggering code:

    TypedQuery<NewsagentSubscriberQueue> query = entityManager.createNamedQuery("NewsagentSubscriberQueue.getUnprocessedSubscribersByUsn", NewsagentSubscriberQueue.class);
    query.setParameter("usn", usn);
    List<NewsagentSubscriberQueue> queue = query.getResultList();  <-- Exception thrown here
Re: Eclipselink is attempting to convert fields it's not supposed to [message #1719184 is a reply to message #1719081] Wed, 06 January 2016 00:08 Go to previous message
David Wheeler is currently offline David WheelerFriend
Messages: 6
Registered: November 2015
Junior Member
Ahha, found the problem. Naturally it was our code and not EclipseLink

One of our converters was a bit over-zealous with it's setting up of UUIDs:

public class UUIDConverter implements org.eclipse.persistence.mappings.converters.Converter
{
  private static final long serialVersionUID = 1L;

  @Override
  public UUID convertObjectValueToDataValue(Object objectValue, Session session)
  {
    return (UUID) objectValue;
  }

  @Override
  public UUID convertDataValueToObjectValue(Object dataValue, Session session)
  {
    return (UUID) dataValue;
  }

  @Override
  public boolean isMutable()
  {
    return false;
  }

  @Override
  public void initialize(DatabaseMapping mapping, Session session)
  {
    DatabaseField field = mapping.getField();
    field.setSqlType(Types.OTHER);
    field.setTypeName("java.util.UUID");
    field.setColumnDefinition("UUID");

    for (DatabaseMapping m : mapping.getDescriptor().getMappings())
    {
      if (m instanceof OneToOneMapping)
      {
        for (DatabaseField relationshipField : ((OneToOneMapping) m).getForeignKeyFields())
        {
          relationshipField.setSqlType(Types.OTHER);
          relationshipField.setColumnDefinition("UUID");
          relationshipField.setTypeName("java.util.UUID");
        }
      }
    }
  }

}


As you can see, it sets ALL fields to be UUIDs, not just the one it's dealing with! I'm pretty sure we got this off the internet, so I guess that's what we get for not understanding what we're doing!
Previous Topic:ReplicationDriver
Next Topic:Doing an Oracle db query with a PL/SQL Function in where clause
Goto Forum:
  


Current Time: Fri Mar 05 05:23:23 GMT 2021

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

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

Back to the top