[Persistence,JBoss/CMP, Hibernate, Database] - How to delete relations in entities, idÃÂôs are not the
by NSchweig
Hi,
I have a webapplication with jsf and ejb.If I try to delete relations between entities I always run into the same problem. The id of the objects are not the same so I can delete them from the list.
For example:
Relation Course/CmtUser
Course.java
| @ManyToMany(fetch=FetchType.EAGER)
| @IndexColumn(name="INDEX_COL")
| private List<CmtUser> participants = new ArrayList<CmtUser>();
CmtUser.java
@ManyToMany(mappedBy="members", fetch=FetchType.EAGER)
| @IndexColumn(name="INDEX_COL")
| private List <CmtGroup> groups = new ArrayList<CmtGroup>();
Joining a course is not the problem:
JSF-managedbean CourseBean:
public void joinCourse(){
| currentUser = userHandler.getCmtUserByUserName(getRemoteUserName());
| courseHandler.joinCourse(getCurrentCourseId(),currentUser);
| }
But if I try to "leave a course" (delete user from course-participant-list) it does not work.
I tried it in several ways:
1. Way
The managedbean CourseBean invokes the handler and gives the objects to it:
public void leaveCourse(){
| courseHandler.leaveCourse(currentCourse, currentUser);
| }
Then in the handler I tried to remove the user from the course and vice versa
public void leaveCourse(Course c, CmtUser user) {
| c.getParticipants().remove(user);
| user.getCourses().remove(c);
| em.merge(c);
| em.merge(user);
| }
Problem: Cannot remove the user from c. participants because the id from the user I not the same as the user in the list participants.
The same problem in the 2. Way
2. Way
The managedbean CourseBean invokes the handler:
public void leaveCourse(){
| courseHandler.leaveCourse(currentCourse.getId(), currentUser.getId());
| }
CourseHandler.java
public void leaveCourse(Long courseId, Long userId) {
| Course course = getCourse(courseId);
| CmtUser user = userHandler.getCmtUser(userId);
|
| course.getParticipants().remove(user);
| user.getCourses().remove(course);
| em.merge(user);
| em.merge(course);
| }
If I look into course.participants the id from the user in it is another than the id from the user I got with my userHandler with userHandler.getCmtUser(userId);.
3. Way:
I remove the elements from the list in the jsfmanagedbean CourseBean:
public void leaveCourse(){
| currentCourse.getParticipants().remove(currentUser);
| currentUser.getCourses().remove(currentCourse);
| courseHandler.updateCourse(currentCourse);
| userHandler.updateUser(currentUser);
| }
The only thing I do in the ejbhandler is to update the objects:
CourseHandler.java
public void updateCourse(Course course) {
| em.merge(course);
| }
|
UserHandler.java
public void updateUser(CmtUser cmtUser) {
| em.merge(cmtUser);
| }
But it is the same problem.
How do I solve this? Which is the best way to implement this things; in the jsfmanagedbean or in the ejbhandlers?
Please I need your help.
Thanks Nicki
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4197325#4197325
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4197325
17 years, 4 months
[JBoss Messaging] - Re: JBM Messages stuck in Cluster Environment
by timfox
"s.gasse" wrote : Hi,
|
| thanks for the reply. The problem is somehow solved now, since our system uses message selectors and we found out, that this is actually not supported by a clustered JBM implementation.
Message selectors only work on the *local" destination.
This has been discussed many times over the years, but in general multiple message selectors on queues is considered an anti-pattern?
Why? Because you need to scan the entire queue to see if one matches every time you deliver a message. ==> slow!
On a cluster that's compounded even further. You'd have to scan every message on every server to see if one matches. ==> Horrible performance.
BTW this is not JBM specific. You'll find the same issues with pretty much any messaging system.
If you're effectively using selectors to "select" messages from a "table", then you're basically using the messaging system like a database, and that's not what messaging systems are for.
If you wish that table then you're basically expecting the messaging system to behave like a clustered database, which is not what it is designed to do!
Perhaps something like Oracle RAC would be a better fit.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4197317#4197317
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4197317
17 years, 4 months
[EJB/JBoss] - ClassNotFoundException while lookup a Service
by luckybird
Hi all,
I'm using quartz 1.6.3 and JBoss 4.2.2GA (with ejb3). I have deployed an ear file and inside this are some ejbs and servlets. Furthermore, I have a Job scheduled in a quartz service that triggers a method from a servlet. If the job begins to run, it starts the method (which is from a jar file inside the ear). Inside my method I have to lookup an EJB from JNDI. The ejb classes are located in the same ear file. Now, the method is compaining about ClassNotFoundException, because it can't find any class outside the jar which contains the servlet. Perhaps this sounds a little sophisticated, therefore a little example helps. (no code, just pseudocode)
| MyServletClass implements Job{
| execute() {
| OtherBean b = lookup(OtherBean);
| b.doSomething();
| }
| }
|
My EAR file contains the following:
MyServletJar.jar (which contains MyServletClass)
MyBeans.jar (which contains the ejbs)
SomeOtherStuff.jar
If I start the execute() method "manually" (i.e. per mbean call from webinterface), it is executed correctly.
It seams, that quartz runs in another classloader and therefore it can't find my other classes from ear. How can I make this work???
TIA,
Ralf.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4197313#4197313
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4197313
17 years, 4 months
[JBoss jBPM] - Re: jBPM 3.3.0GA and Oracle causing StaleObjectStateExceptio
by jjrs
Hi Ronald,
I really appreciate all suggestions (it doesn't matter if they are a final solution or just a hack to make it work).
I have just tried to introduce a delay of 8 seconds in one of the actions of the parallel nodes, and I still get the SOE.
I believe the issue is related with the version column of the father node (token table). The moment a child node is created it will have a reference to the parent node, if we have two children they will have an identical copy/reference to the parent. The parent node is updated from both children when they arrive to the join, so I believe it doesn't matter the order or the delay between them, as the copy of one of the child will be out of date the moment is finished (the other node will have updated it when it finishes and arrives to the join) and therefore get the SOE.
I have done a small test changing manually the value of the version column of the parent token, if I decrease it by 1, after one of the child has finished and the other is waiting, I don't get the SOE.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4197309#4197309
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4197309
17 years, 4 months