Open GoogleCodeExporter opened 8 years ago
If i put this code in a Stateless bean and try to set manually the
EntityManager by
the setEntityManager method of GenericDao, the result is ok and all operations
done
successfully.
@PersistenceContext(unitName="myPU")
public EntityManager em;
public void testPais() {
PaisDaoImpl pais = new PaisDaoImpl();
pais.setEntityManager(em);
List<Pais> paisList = pais.getAll();
for (Pais p: paisList) {
System.out.println(p.getDescr());
}
}
Original comment by edson.go...@gmail.com
on 3 Dec 2008 at 2:26
Perhaps it would be better to annotate the field EntityManager in GenericDao
with
@PersistenceContext, rather than the setter.
I have imported all source in a project, and made three changes:
1 - annotate the field.
2 - make it protected.
3 - Remove the setter and getter for EntityManager
Subclasses use directly the entity manager, if needed.
Now it seems to work
Original comment by ermanno....@gmail.com
on 22 Dec 2008 at 6:40
I have same problem, how i can fixit? sorry for my english.
Original comment by ccha...@gmail.com
on 11 Sep 2009 at 5:16
You must extend the IDao in the interface and extend GenericDao in your EJB.
Interface Example:
@Local
public interface NotaFiscalReferenDaoLocal extends IDao<NotaFiscalReferen,
Long> {
}
Implementation Example:
/**
* Session Bean implementation class NfReferenDaoBean
*/
@Stateless
public class NotaFiscalReferenDaoBean extends GenericDao<NotaFiscalReferen,
Long>
implements NotaFiscalReferenDaoLocal {
}
NotaFiscalReferen is the Entity, in this case.
Original comment by edson.go...@gmail.com
on 11 Sep 2009 at 5:51
Original issue reported on code.google.com by
edson.go...@gmail.com
on 3 Dec 2008 at 2:22