Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Named queries with dynamic entities?
icon5.gif  Named queries with dynamic entities? [message #992011] Thu, 20 December 2012 12:00 Go to next message
khalil haddad is currently offline khalil haddad
Messages: 12
Registered: November 2012
Junior Member
Hello everyone!

The question is in the title Razz
I have some dynamic entities and I want to have named query on them.
The problem is that my dynamic entities are created after my spring context is fully loaded so EclipseLink does not know them at startup.

Is there a way to create dynamic entities at startup before compilation of the named queries? Very Happy
I tried to look at Session customizers but I didn't find how to get an entity manager from a session.
Re: Named queries with dynamic entities? [message #992368 is a reply to message #992011] Fri, 21 December 2012 08:29 Go to previous message
khalil haddad is currently offline khalil haddad
Messages: 12
Registered: November 2012
Junior Member
Solution found!

public class AuditCustomizer implements SessionCustomizer{
	@Override
	public void customize(Session session) throws Exception {
        	DynamicClassLoader dcl = DynamicClassLoader.lookup(session);
        	DynamicHelper helper = new JPADynamicHelper(JpaHelper.createEntityManagerFactory(session.getProject().createServerSession()));
		...
	}
}


and add this to your persistence unit :

<property name="eclipselink.session.customizer" value="<full package>.AuditCustomizer"/>
Previous Topic:JAXB with Eclipse RCP
Next Topic:browse eclipselink maven repository
Goto Forum:
  


Current Time: Wed Jul 23 16:21:47 EDT 2014

Powered by FUDForum. Page generated in 0.01558 seconds