Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Multiple inheritance and NotSerializableException
Multiple inheritance and NotSerializableException [message #769083] Wed, 21 December 2011 11:16 Go to next message
kRu Missing name is currently offline kRu Missing nameFriend
Messages: 5
Registered: June 2011
Junior Member
Hi,

I'm encountering the following problem:

If I try to create a query the following way (this is instanceof AbstractGrouping)
db.createQuery("SELECT a FROM AbstractGrouping a WHERE a.previousGrouping=?1", AbstractGrouping.class).setParameter(1, this).getResultList();

I get this exception:
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLException: Serialisierung fehlgeschlagen, Grund: "java.io.NotSerializableException: de.data.entities.SystemLevel"
Serialization failed, cause: "java.io.NotSerializableException: de.data.entities.SystemLevel" [90026-161]
Error Code: 90026
Call: SELECT ID, DESCRIPTION, DISPLAYNUMBER, NAME, TYPE, PREVIOUSGROUPING_ID FROM ABSTRACTGROUPING WHERE (PREVIOUSGROUPING_ID = ?)
	bind => [de.data.entities.SystemLevel@b0ede6]
Query: ReadAllQuery(referenceClass=AbstractGrouping sql="SELECT ID, DESCRIPTION, DISPLAYNUMBER, NAME, TYPE, PREVIOUSGROUPING_ID FROM ABSTRACTGROUPING WHERE (PREVIOUSGROUPING_ID = ?)")
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:644)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535)
	at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1717)
	at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:253)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:646)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2611)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2570)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:420)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1081)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:844)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1040)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:392)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1128)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2871)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1516)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1498)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1463)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
	at de.data.entities.AbstractGrouping.getNextGroupings(AbstractGrouping.java:53)
...

Caused by: org.h2.jdbc.JdbcSQLException: Serialisierung fehlgeschlagen, Grund: "java.io.NotSerializableException: de.data.entities.SystemLevel"
Serialization failed, cause: "java.io.NotSerializableException: de.data.entities.SystemLevel" [90026-161]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
	at org.h2.message.DbException.get(DbException.java:158)
	at org.h2.util.Utils.serialize(Utils.java:239)
	at org.h2.value.DataType.convertToValue(DataType.java:945)
	at org.h2.jdbc.JdbcPreparedStatement.setObject(JdbcPreparedStatement.java:426)
	at org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.setParameterValueInDatabaseCall(DatabasePlatform.java:2235)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:716)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:585)
	... 75 more

Caused by: java.io.NotSerializableException: de.data.entities.SystemLevel
	at java.io.ObjectOutputStream.writeObject0(Unknown Source)
	at java.io.ObjectOutputStream.writeObject(Unknown Source)
	at org.h2.util.Utils.serialize(Utils.java:236)
	... 80 more


I think that the problem is related to the fact that I'm using a "multiple" inheritance structure, which looks like this:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
abstract public class AbstractEntity
{
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	protected long id;
	...
}

@Entity
abstract public class AbstractEntityWithName extends AbstractEntity
{
	...
}

@Entity
abstract public class AbstractEntityWithNameAndDescription extends AbstractEntityWithName
{
	...
}

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
abstract public class AbstractGrouping extends AbstractEntityWithNameAndDescription
{
	@ManyToOne(optional = true, fetch = FetchType.LAZY)
	@JoinColumn(name = "PREVIOUSGROUPING_ID", nullable = true)
	private AbstractGrouping previousGrouping;

	transient private List<AbstractGrouping> nextGroupings;
	public List<AbstractGrouping> getNextGroupings ()
	{
		if (nextGroupings == null)
		{
			nextGroupings = db.createQuery("SELECT a FROM AbstractGrouping a WHERE a.previousGrouping=?1", AbstractGrouping.class).setParameter(1, this)
					.getResultList();
		}
		return nextGroupings;
	}
}

// this is the class which throws the not-serializable exception
public class SystemLevel extends AbstractGrouping
{
	// contains nothing
}


Trying to let SystemLevel implement Serializable gives another strange error:
Hexadecimal string with odd number of characters: "1"; SQL statement:
SELECT ID, DESCRIPTION, DISPLAYNUMBER, NAME, TYPE, PREVIOUSGROUPING_ID FROM SCENARIOFIELD WHERE (PREVIOUSGROUPING_ID = ?) [90003-161]
Error Code: 90003
Call: SELECT ID, DESCRIPTION, DISPLAYNUMBER, NAME, TYPE, PREVIOUSGROUPING_ID FROM SCENARIOFIELD WHERE (PREVIOUSGROUPING_ID = ?)
	bind => [de.data.entities.SystemLevel@487c5f]


I was already trying to find some information about this issue, but I couldn't find any.

I have this issue also a second time, where I'm trying to create in a concrete class a reference to some abstract type.

Additional information:
- Equinox OSGi
- EclipseLink 2.3.2.v20111125-r10461
- All classes in one single bundle/package
- DB is H2 version 1.3.161
- Changing the database to hsqldb doesn't help (gives basically the same error, other wording)
- All getter/setter are defined
- Changing the @Inheritance strategy for AbstractGrouping gives PreDeployment errors

Any input for fixing this or just a work-around would be appreciated.

Thanks in advance for your help,
Johannes
Re: Multiple inheritance and NotSerializableException [message #769731 is a reply to message #769083] Thu, 22 December 2011 15:50 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The serialization error occurs because EclipseLink is not translating the object parameter into its Id value.
It should do this, and is odd that it is not. It could be related to the TABLE_PER_CLASS inheritance you are using.
If you can try it without the TABLE_PER_CLASS inheritance to see if it works, if it does then log a bug.

An easy workaround is to just use the id,

db.createQuery("SELECT a FROM AbstractGrouping a WHERE a.previousGrouping.id=?1", AbstractGrouping.class).setParameter(1, this.getId()).getResultList();


James : Wiki : Book : Blog : Twitter
Previous Topic:Command line EclipseLink
Next Topic:Eclipselink force update
Goto Forum:
  


Current Time: Thu Mar 28 21:07:33 GMT 2024

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

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

Back to the top