Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problems using the @ClassExtractor annotation
Problems using the @ClassExtractor annotation [message #953265] Mon, 22 October 2012 05:28 Go to next message
Cyrill Zadra is currently offline Cyrill ZadraFriend
Messages: 3
Registered: October 2012
Junior Member
Hi there

I'm having problems using the classextractor annotation.. so I tried to reproduce the problem in a simple example.
In this example there are 2 entities. The entity Car and the entity vw which extends car. The classextractor class does always return a Car.class.

@SequenceGenerator(name = "CarIdGenerator")
public class Car implements Serializable {

	@GeneratedValue(generator = "CarIdGenerator")
	private long carId;

	private String name;
	private String descr;
	private static final long serialVersionUID = 1L;

	public Car() {

public class VW extends Car implements Serializable {
	private String color;
	private static final long serialVersionUID = 1L;

	public VW() {

public class TypeExtractor extends ClassExtractor {
	public Class extractClassFromRow(Record databaseRow, Session session) {
		return Car.class;



Here's the code snippet where I create the car instance an persist it to the database.

   Car car = new Car();
   car.setName("Super Car");
   car.setDescr("Fast and Super");

[EL Finer]: 2012-10-21 21:04:08.987--ClientSession(1547555875)--Connection(39892115)--Thread(Thread[main,5,main])--begin transaction
[EL Fine]: 2012-10-21 21:04:08.987--ClientSession(1547555875)--Connection(39892115)--Thread(Thread[main,5,main])--INSERT INTO CAR (CARID, DESCR, NAME) VALUES (?, ?, ?)
	bind => [1, Fast and Super, Super Car]
[EL Finer]: 2012-10-21 21:04:08.996--ClientSession(1547555875)--Connection(39892115)--Thread(Thread[main,5,main])--commit transaction

.. but refreshing the newly created instance returns always an EntityNotFoundException


Exception in thread "main" javax.persistence.EntityNotFoundException: Entity no longer exists in the database: ch.tie.poc.jpa.Car@2b177c9.
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.refresh(
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.refresh(
	at ch.tie.poc.jpa.Main.main(

[EL Finest]: 2012-10-21 22:19:49.994--UnitOfWork(1189942303)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=Car )
[EL Finest]: 2012-10-21 22:19:49.995--ServerSession(1313157506)--Connection(1456488724)--Thread(Thread[main,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2012-10-21 22:19:49.995--ServerSession(1313157506)--Connection(1456488724)--Thread(Thread[main,5,main])--SELECT t0.CARID, t0.DESCR, t0.NAME, t1.CARID, t1.COLOR FROM CAR t0, VW t1 WHERE ((t0.CARID = ?) AND (t1.CARID = t0.CARID))
	bind => [1]
[EL Finest]: 2012-10-21 22:19:49.998--ServerSession(1313157506)--Connection(1456488724)--Thread(Thread[main,5,main])--Connection released to connection pool [default].

And looking at the log you can see its joining the two tables car an vw. What am I doing wrong? Shouldn't it only select the car table? Hope someone can give me a hint.

Could reproduce this with eclipselink 2.3.3 and 2.4.0.

thanks and regards
Re: Problems using the @ClassExtractor annotation [message #954014 is a reply to message #953265] Mon, 22 October 2012 18:19 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1369
Registered: July 2009
Senior Member
Hello Cyrill,

Please file a bug and vote for it, as it likely should be using an outer join if it is going to join at all.

According to
a single table inheritance strategy requires setting a onlyInstancesExpression using a descriptor customizer that it will use when forming the queries. Because Car and VW are sharing the car table, adding an expression for Car will workaround the issue and prevent the join.

Best Regards,
Re: Problems using the @ClassExtractor annotation [message #954461 is a reply to message #954014] Tue, 23 October 2012 02:41 Go to previous message
Cyrill Zadra is currently offline Cyrill ZadraFriend
Messages: 3
Registered: October 2012
Junior Member
Thanks for your response. Can I use a descriptor customizer also with InheritanceType.JOINED?

I filed a bug and voted for it .. see

Previous Topic:using eclipselink in Eclipse' Tomcat
Next Topic:JPA mapping problem. Multiple values
Goto Forum:

Current Time: Mon Sep 28 06:08:53 GMT 2020

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

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

Back to the top