-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Please any help - EJB5018 with EM on entity delete
PostPosted: Mon Apr 07, 2008 4:55 pm 
Newbie

Joined: Mon Apr 07, 2008 4:23 pm
Posts: 2
I have attempted to search thru the discussions on this but have not found anything

I am using netbeans6.0.1 for dev
Glassfish V2
Postgres 8.1.10
JPA at the EJB tier uses Hibernate EntityMananger 3.3.2 to wrk with the DB

I have a table Reminders (well it is suppose to keep track of reminders for a user). My app has a web tier, and ejb tier and db; web queries a user's reminders and shows it to him/her. User selects the reminders he/she wants to delete ... which then goes back to the ejb layer for deletion via EM/JPA

Querys of existing and Inserts for new reminders work perfectly ... When I attempt to delete the Reminders record it bombs ... with a stack trace; in the stack trace I dont see any causedby

Here is the code (the bolded line is where I am seeing the prblem ... well after the method returns and the tran get comitted)
I have put a break point and looked into the reminders object and all appears ok

Code:
@Stateless
public class RemindersFacade implements RemindersFacadeRemote {
    @PersistenceContext
    private EntityManager em;

    public void create(Reminders reminders) {
        em.persist(reminders);
    }

    public void edit(Reminders reminders) {
        em.merge(reminders);
    }

    public void remove(Reminders reminders) {
[b]        em.remove(em.merge(reminders));[/b]
    }

    public Reminders find(Object id) {
        return em.find(com.repairtime.jpa.entities.generated.Reminders.class, id);
    }

    public List<Reminders> findAll() {
        return em.createQuery("select object(o) from Reminders as o").getResultList();
    }

}


Any help is appreaciated.
ps: I tried with Toplink that comes with the default NB, and that worked - I dont want to use Toplink however


===========================
Need help with Hibernate? Read this first: I have
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: hibernate-3.2.6.GA

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
EJB5018: An exception was thrown during an ejb invocation on [RemindersFacade]
javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:440)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:371)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3571)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:210)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
at $Proxy90.remove(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:233)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
at com.repairtime.ejb.session.generated.__RemindersFacadeRemote_Remote_DynamicStub.remove(com/repairtime/ejb/session/generated/__RemindersFacadeRemote_Remote_DynamicStub.java)
at com.repairtime.ejb.session.generated._RemindersFacadeRemote_Wrapper.remove(com/repairtime/ejb/session/generated/_RemindersFacadeRemote_Wrapper.java)


Name and version of the database you are using:
Postgre
8.1.10

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?
No
Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 11:37 pm 
Newbie

Joined: Mon Apr 07, 2008 4:23 pm
Posts: 2
Some interesting find ...

if I change the logic in the facade, i am able to make it work

Code:
    public void remove(Reminders reminders) {
        reminders = find(reminders.getRemindersid());
        em.remove(em.merge(reminders));
    }

But then the question is why? It shouldn't require me to do a find ... because it is thr same obj that was stored in the web session earlier on.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.