users@glassfish.java.net

Re: JEE 6 / Glassfish v3 / Eclipse - JPA Entity Manager Issues

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Wed, 07 Apr 2010 21:44:43 -0700

Try unitName instead of name.

-marina

glassfish_at_javadesktop.org wrote:
> Alrighty guys, I took the advice and ended up restructuring my project.
>
> EAR
> - EJB
> - WAR
>
> My EJB project has the JPA facet so I could use Eclipse to generate Entities from the database tables. There I also have my persistence.xml
>
> Persistence.xml
> ============
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
> <persistence-unit name="jdbc/RDF" transaction-type="JTA">
> <jta-data-source>jdbc/RDF</jta-data-source>
> <properties/>
> </persistence-unit>
> </persistence>
>
> EJB
> ====
> @LocalBean
> @Stateless
> public class UserController
> {
> @PersistenceContext(unitName = "jdbc/RDF")
> private EntityManager em1;
>
> @PersistenceContext(unitName = "jdbc/RDF")
> private EntityManager em2;
>
> @PersistenceContext
> private EntityManager em3;
>
> @PersistenceContext(name = "jdbc/RDF")
> private EntityManager em4;
>
> @PersistenceContext(name = "jdbc/RDF")
> private EntityManager em5;
>
> @PersistenceContext
> private EntityManager em6;
>
> public UserController()
> {
> }
>
> public void insert(User user)
> {
> em1.persist(user);
> }
>
> }
>
> Once again.... all of my entity managers are NULL.
>
> Any other thoughts?
> [Message sent by forum member 'iceman3479']
>
> http://forums.java.net/jive/thread.jspa?messageID=395815
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>