[EJB 3.0] - Not understanding detached entities and merge()
by SmokingAPipe
Here's the situation:
I have an entity that refers to other entities, like this:
@Entity public class Invoice implements Serializable {
| @ManyToOne private transient Customer customer;
| }
It must implement Serializable so I can send it to message queues.
I labeled the customer field as transient, because I don't want it to serialize and send the entire Customer object every time (that object has a bunch of its own fields).
So, because that's transient, this Invoice entity shows up, is de-seriaiized, and the customer field is null of course.
I then do
invoice = entityManager.merge(invoice);
to re-attach this now-detached entity. But when I do that, the customer field gets set to null in the DB. It is taking the state from the un-serialized object and writing over what's in the DB.
That's not what I want it to do, of course.
What's the right way to do this kind of thing? An easy work around I have is to use entityManager.find(Invoice.class, invoice.getId()) but that seems wrong.
Ideas?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016805#4016805
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016805
19Â years, 2Â months
[JBoss Messaging] - Re: Receiving IllegalStateExceptions in client
by bander
"timfox" wrote :
| So you're creating a set of message listeners on the same session, and you're saying this gives you the aforementioned problem?
|
| What are you doing in your message listeners? Are you accessing the session at all?
No sorry. I've got that wrong.
We're using a single thread to create a set of sessions. Each session has a single consumer (not multiple consumers per session as I stated earlier). Each consumer is configured with a message listener.
Previously our test was using a single thread to create 5 sessions, with one consumer/listener per session. This was causing frequent IllegalStateExceptions.
When I reconfigured the test to only create one session, with one consumer/listener the problem appears to go away.
The message listener used by each consumer is actually a singleton that simply stores the received payload so we can compare it with what was sent at the end of the test:
| public void onMessage(Message message) {
| // extract payload and received queue name and pass to test coordinator
| // for processing
| try {
| String queueName = ((Queue) message.getJMSDestination())
| .getQueueName();
| Object payload = null;
| if (message instanceof TextMessage) {
| payload = ((TextMessage) message).getText();
| } else if (message instanceof ObjectMessage) {
| payload = ((ObjectMessage) message).getObject();
| } else {
| throw new RuntimeException(
| "Received unexpected JMS message type: "
| + message.getClass());
| }
| getMessageStore().store(queueName, payload);
| } catch (Exception ex) {
| throw new RuntimeException(//
| "Failed to process received message", ex);
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016800#4016800
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016800
19Â years, 2Â months
[JBoss Portal] - Re: Google Gadgets
by Oberiko
Hi Julien, thanks for responding.
I never tried the "dynamic" gadgets (sorry, I'm not sure what the proper terminology is, "stateful"?), as in my admittedly limited search I haven't noticed any particularly useful ones for a corporate site.
Still, since the whole point was that Gadgets seem to grow like weeds, a useful one is likely to appear and not being able to maintain the widget state is a definite, if not immediate, limitation.
But, if I read you correctly, JBoss supports Google Gadgets? Would you happen to have an example on hand you could point me to?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016795#4016795
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016795
19Â years, 2Â months
[Installation, Configuration & Deployment] - Re: Deployment problem after Isolated Classpath config
by jjay009
I removed the commons-digester.jar file from the EAR file. Now I am getting following error.
---------------------------------------------------------------------------------------------------------------------------------------------------------------
ERROR [ActionServlet] Unable to initialize Struts ActionServlet due to an unexpected exception or error thrown, so marking the servlet as
unavailable. Most likely, this is due to an incorrect or missing library dependency.
java.lang.NoClassDefFoundError: org/apache/commons/chain/config/ConfigParser
at org.apache.struts.action.ActionServlet.initChain(ActionServlet.java:1625)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:347)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3951)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4225)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
---------------------------------------------------------------------------------------------------------------------------------------------------------------
How do I fix this error?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016787#4016787
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016787
19Â years, 2Â months