Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366952 - Cannot use Criteria API when creating EntityManagerFactory with an existing ServerSession
Summary: Cannot use Criteria API when creating EntityManagerFactory with an existing S...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-16 10:49 EST by Ilyes Ben Hassen CLA
Modified: 2022-06-09 10:27 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ilyes Ben Hassen CLA 2011-12-16 10:49:48 EST
Build Identifier: 

According to the Eclipselink javadoc it is possible to create an EntityManagerFactory with a ServerSession.
The EntityManager created is able to execute JPQL but not Criteria API.

see following code snippt:

ServerSession serverSession = EclipselinkService.getInstance().getServerSession()
	EntityManagerFactory entityManagerFactory = JpaHelper.createEntityManagerFactory(serverSession);
	EntityManager entityManager = entityManagerFactory.createEntityManager();
	CriteriaBuilder cb = entityManager.getCriteriaBuilder();
			
Following exception is thrown since setupImpl is null:

java.lang.NullPointerException at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getMetamodel(EntityManagerFactoryDelegate.java:592)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getCriteriaBuilder(EntityManagerFactoryDelegate.java:566)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.getCriteriaBuilder(EntityManagerImpl.java:2287)

Note: Our data model is created automatically, so it hard to use JPA annotation or XML mapping, we create however owr own org.eclipse.persistence.sessions.Project and therefore a ServerSession.
How can we reuse these objects to construct a full-feature EntityManagerFactory?

Reproducible: Always
Comment 1 Tom Ware CLA 2012-01-23 10:41:26 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:27:08 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink