[EJB 3.0] - Re: problem with test invocation of session bean
by dmitryak
ok.
I will try to help you, but i am not sure that I can. :))
try to change your code
public class TestSessImpl implements TestSession, TestSessionRem{
| @PersistenceUnit(unitName="hotel")
| private EntityManagerFactory entityFactory;
| private EntityManager entityManager;
|
to
public class TestSessImpl implements TestSession, TestSessionRem{
| @PersistenceContext
| private EntityManager entityManager;
|
and
public TestEntity saveTestEntity(TestEntity entity) {
| try{
| EntityManager manager = entityFactory.createEntityManager();
| manager.persist(entity);
| }catch(Exception ex){
| System.out.println(ex.getMessage());
| }
| return entity;
| }
to
public TestEntity saveTestEntity(TestEntity entity) {
| return manager.persist(entity);
| }
If it doesn't help let me know...
P.S. I am sorry for my english
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3999852#3999852
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3999852
19 years, 3 months
[EJB 3.0] - Failed to lazily initialize a collection of role
by dmitryak
Hi...
I don't speak English very well, so I apologise for that.
I have a problem.
I have made Entity Bean with collection field:
| @Entity
| public class DocumentEntity implements Serializable {
|
| private static final long serialVersionUID = 4842258583854141368L;
|
| private int id;
|
| private List<DocCategoryEntity> docCategories;
|
| @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
| public List<DocCategoryEntity> getDocCategories() {
| return docCategories;
| }
|
| public void setDocCategories(List<DocCategoryEntity> categories) {
| this.docCategories = categories;
| }
| ...
| }
|
I deployed it on JBoss 4.0.4GA + EJB 3.0 RC8 FD.
After that I made a junit which read a list of DocumentEntity-s (of course, I coded and deployd session bean which provide requered operations).
And my problem is: when I try to read docCategories field of any item of result list I get an exception "org.hibernate.LazyInitializationException"
But as you can see in my entity class source I am not using lazy loading (FetchType.EAGER). What did I make wrong???
Help, PLEASE!!!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3999838#3999838
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3999838
19 years, 3 months