SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Joined: Jun 20, 2009
i know that its a type mismatch but how can i build my entityManager bean?
when i try to do something like: <bean id="entityManager" class="javax.persistence.EntityManager"> it says it is an interface and not a class...
Looking at the Javadocs for PersistenceAnnotationBeanPostProcessor
"This post-processor will inject sub-interfaces of EntityManagerFactory and EntityManager if the annotated fields or methods are declared as such. The actual type will be verified early, with the exception of a shared ("transactional") EntityManager reference, where type mismatches might be detected as late as on the first actual invocation. "
Hmmm type mismatches.
I also found this interesting
"Note: A default PersistenceAnnotationBeanPostProcessor will be registered by the "context:annotation-config" and "context:component-scan" XML tags."
This last one would explain why you want to have the PersistenceAnnotationBeanPostProcessor commented out because you already have the context:annotation-config tag
Joined: Jun 20, 2009
i tried it now with @Autowired on the field / on the setter method of the Factory and included this in my applicationContext:
and removed the LectureDaoImpl bean and the BeanPostProcessor... still nullpointerexception...
Where is your Service layer, you have a DAO directly in your Controller and skip the Service Layer. The Service layer is the Use Case business logic layer and is the most common, and in my opinion, best place to start your transactions.
Seems redundant to me. Since you have an injection of the entityManagerFactory directly into the lectureDao bean, why do you also need the Annotation of @PersistenceContext for the PersistenceAnnotationBeanPostProcessor?
Joined: Jul 05, 2005
Use this current configuration, remove all Annotations from LectureDaoImpl, and debug setEntityManagerFactory, I expect it should get called.
ganzgeheim is german and means "topsecret", so i think this shouldnt be a security problem ;)
i'm really new to spring and this web/portlet development... and i thought the LectureDao is my service layer?
will try it this evening...
edit: entityManagerFactory is set
btw. what i did: removed all annotations from LectureDaoImpl, removed <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
the lectureDao in my controller is also set (seen during debugging), but when i try to access the portlet, lectureDao is null