Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-26-2007, 08:37 PM
Member
 
Join Date: Jul 2007
Posts: 1
makcro is on a distinguished road
problem with ejb 3.0 entity beans with manyToMany relationship
Hello everyone!
I am using struts 1.2.9 and java ee 5 sdk update 2 for my enterprise application. Besides others i have these entity beans Targetgroup.java and City.java, City.txt

targetgroup.txtwith manytomany relationship.
when user updates Targetgroup, by clicking on web page with checkboxes and textfields, struts dispatch action calls following method stateless bean:

public void update(String firmId, String targetgroupId, String newGender, String newMinYearsOld, String newMaxYearsOld, String[] newCities) {
TargetgroupPK pkForUpdate = new TargetgroupPK(targetgroupId, firmId);
Targetgroup targetgroupForUpdate = find(pkForUpdate);

targetgroupForUpdate.setGender(newGender);
targetgroupForUpdate.setMinyearold(Integer.parseIn t(newMinYearsOld));
targetgroupForUpdate.setMaxyearold(Integer.parseIn t(newMaxYearsOld));

//pronalazenje gradva za koje je vezana ciljna grupa
Collection<City> newCitiesCollection = new ArrayList<City>();

for(int i = 0; i < newCities.length; i++){
String tmp_city_name = newCities[i];
City city_obj = cityFacade.find(tmp_city_name);
newCitiesCollection.add(city_obj);
}
targetgroupForUpdate.setCityidCollection(newCities Collection);



}

parameter newCities represents names of cities which user checked on his update page. When the page is showen to him some cities are allready check because they were connected with Targetgruoup when it was created (targetgroup).
this code throws following exception:

[#|2007-07-26T12:13:36.993+0200|SEVERE|sun-appserver-pe9.0|javax.enterprise.system.container.web|_Threa dID=16;_ThreadName=httpWorkerThread-8080-0;_RequestID=f79d9c50-86b0-4b6c-96ab-97956dfb39c1;|StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
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.web.connector.grizzly.WorkerTh read.run(WorkerThread.java:75)
javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.ejb.containers.BaseContainer.completeNewTx (BaseContainer.java:3659)
at com.sun.ejb.containers.BaseContainer.postInvokeTx( BaseContainer.java:3431)
at com.sun.ejb.containers.BaseContainer.postInvoke(Ba seContainer.java:1247)
at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:1 92)
at com.sun.ejb.containers.EJBLocalObjectInvocationHan dlerDelegate.invoke(EJBLocalObjectInvocationHandle rDelegate.java:71)
at $Proxy149.update(Unknown Source)
at audiotel.sms.actions.backoffice.TargetgroupDispatc hAction.updateOrDelete(TargetgroupDispatchAction.j ava:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchM ethod(DispatchAction.java:270)
at org.apache.struts.actions.DispatchAction.execute(D ispatchAction.java:187)
at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:727)
com.sun.enterprise.web.connector.grizzly.WorkerThr ead.run(WorkerThread.java:75)
|#]

exceprion is throwen ONLY when in parameter newCities are city names allready connected to Targetgroup. when NewCities contains names of
City objects which are not connected to Targetgroup it works fine, but it's of no use for me, because user must be able to add or remove certian cities from relaionship with Targetgroup. I think it's because there are rows in join table that contain primary keys of city and targetgroup which are connected so perisistence manager cann't write them again.
i thought it was going to figure it out by itself, and only update those rows.

Does anyone know what is the problem and solution?
Thanks! (forgive my spelling errors
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
EJB - Entity Beans III JavaForums Java Blogs 0 04-04-2008 04:10 PM
EJB - Entity Beans II JavaForums Java Blogs 0 04-04-2008 04:10 PM
EJB - Entity Beans I JavaForums Java Blogs 0 04-03-2008 07:21 PM
PK for Entity beans eva Enterprise JavaBeans 2 01-03-2008 05:51 AM
Entity Beans in JBOSS dcpmt Enterprise JavaBeans 0 11-29-2007 03:49 PM


All times are GMT +3. The time now is 02:54 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org