Skip to main content


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 17:00 Go to next message
khalil haddad is currently offline khalil haddadFriend
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 13:29 Go to previous message
khalil haddad is currently offline khalil haddadFriend
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: Thu Apr 25 15:49:01 GMT 2024

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

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

Back to the top