Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Strange behavior in loading entities
Strange behavior in loading entities [message #632039] Mon, 11 October 2010 06:20 Go to next message
Eclipse UserFriend
I am working on a project to migrate from Hibernate to EclipseLink 2.1.1.

I list all my entities in the persistence.xml using <class> tags. However, when I use entityManagerFactory.getMetamodel.getEntities(). Nothing is returned.

But the weird thing is: when I remove all the <class> tags, I can get Entity3 from the getEntities() method but not all.
It would be greatly appreciated if someone has a hint for this problem.

I am using Spring 3.0.3, EclipseLink 2.1.1.

persistence.xml:
   <persistence-unit name="mainPU" transaction-type="RESOURCE_LOCAL">
      <class>foo.bar.Entity1</class>
      <class>foo.bar.Entity2</class>
      <class>foo.bar.Entity3</class>
      <class>foo.bar.Entity4</class>

      <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
      <validation-mode>NONE</validation-mode>
      
   </persistence-unit>


spring bean in xml:
	<bean id="mainEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="persistenceXmlLocation" value="classpath:config/persistence.xml" />
		<property name="persistenceUnitName" value="mainPU"/>
		<property name="persistenceProviderClass" value="org.eclipse.persistence.jpa.PersistenceProvider" />
		<property name="jpaProperties">
			<props>
				<prop key="javax.persistence.jdbc.driver">net.sourceforge.jtds.jdbc.Driver</prop>
				<prop key="javax.persistence.jdbc.url">jdbc:jtds:sybase://someURL</prop>
				<prop key="javax.persistence.jdbc.user">xxxx</prop>
				<prop key="javax.persistence.jdbc.password">xxxx</prop>
				
				<prop key="eclipselink.weaving">false</prop>
				
			</props>
		</property>
	</bean>
Re: Strange behavior in loading entities [message #632295 is a reply to message #632039] Tue, 12 October 2010 09:34 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

Can you try obtaining the metamodel from the entityManager rather than the factory? It could be that the persistence unit is being lazy loaded, so only initialized after an entitymanager has been accessed. If so, this might be fixed in the transaction for
https://bugs.eclipse.org/bugs/show_bug.cgi?id=322585


Best Regards,
Chris
Re: Strange behavior in loading entities [message #632535 is a reply to message #632295] Wed, 13 October 2010 06:56 Go to previous message
Eclipse UserFriend
Thanks!!!
Obtaining the metamodel from entityManager solves the problem!!!
Previous Topic:Parsing error in JPQL query
Next Topic:JPQL query does not locate the constructor correctly
Goto Forum:
  


Current Time: Tue Jul 22 22:43:22 EDT 2025

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

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

Back to the top