[EJB 3.0] - Re: Client access to Entity beans
by Doug.Palmer
"fguerzoni" wrote : From Entity Bean tutorial:
|
| Entity Beans have been given a complete overhaul in EJB 3.0. Entity beans are plain Java objects that can be allocated with new and attached/detached/reattached to persistence storage. Entity beans are not remotable and must be access through the new javax.persistence.EntityManager service. JBoss's EJB 3.0 implementation is built on top of Hibernate.
|
| So with ejb3, the facade pattern, is not an option anymore.
|
| bye
| F
Ok, I've put a session bean in front of my entities now, following the MVC pattern. I guess my initial question should have read:
How can I instantiate an Entity Manager on a stand alone client?
I had already figured out that the client couldn't connect directly to an entity bean. However, all of my attempts to instantiate an entity manager on a client failed. Is there a mechanism for starting an entity manager in the client which persists data to a remote Jboss server?
Regards
Doug
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3958297#3958297
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3958297
19 years, 9 months
[Persistence, JBoss/CMP, Hibernate, Database] - Ignoring empty but not-null cascaded entities...
by bluetrade
Hi,
I have a question regarding the possibility to ignore entities dynamically, based on whether or not they contain data. Let me explain:
class Person implements Serializable {
private Information info = new Information();
private String name;
...
}
now I don't want to save the information in case it remains empty, but at the same time I want to make use of the cascading functionality, but at times, Persons don't have information the information object would be empty. I cannot just leave it out, since I work with Seam and info.description for example might be injected, but if that field for example is null, I would like to ignore the info object so that I don't have any null-containing rows in the database. Also the not-null annotation does not help me...
Any ideas?
Thanks!!!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3958295#3958295
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3958295
19 years, 9 months
[EJB/JBoss] - Ignoring empty contained entities
by bluetrade
Hi,
I have a question regarding the possibility to ignore entities dynamically, based on whether or not they contain data. Let me explain:
class Person implements Serializable {
private Information info = new Information();
private String name;
...
}
now I don't want to save the information in case it remains empty, but at the same time I want to make use of the cascading functionality, but at times, Persons don't have information the information object would be empty. I cannot just leave it out, since I work with Seam and info.description for example might be injected, but if that field for example is null, I would like to ignore the info object so that I don't have any null-containing rows in the database. Also the not-null annotation does not help me...
Any ideas?
Thanks!!!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3958294#3958294
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3958294
19 years, 9 months
[Remoting] - Re: Servlet and HTTP invoket does't throw remote method Exce
by mazz@jboss.com
I like the idea of having it configurable - let the web services team configure theirs so it returns the exception, let me configure it so it will throw the exception :-)
I just learned that a recent change now means invoke doesn't return an exception object, instead it returns a String (correct Tom?).
I don't like this. You have no notion that this is really an error. At the very least, if I can't get the exception thrown, I would prefer the object returned by invoke to be an Exception - its getMessage() can return that String that is returned now.
Wrapping in an Exception means at least my caller to invoke will know that a true exception occurred. The stuff I'm working on, I want to use remoting's great feature of just being able to switch transports (in the invoker locator) and have a completely different transport mechanism used. My code never really knows what transport is being used - the customer just configures the locator URL in a config file to what they want to and *poof* they get what they want. If you force me to look at the HTTP return code, that requires my code to assume I am using a servlet or http transport. But that isn't always true. Looking at the return value of invoke() and seeing if it is instanceof Exception is acceptable in my usecase (of course, having an exception getting thrown would be ideal).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3958290#3958290
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3958290
19 years, 9 months
[EJB 3.0] - Re: Problem with containment interacting with inheritance?
by knaveofhearts
I have worked on simplifying my problem, resulting in the following question--could someone please tell me how to, or have a code example of the annotations to configure combining inheritance with a one-to-many relationship among entities (i.e., A is the superclass of B. B contains a Collection of C objects) or for that matter a one-to-one (B contains an C) or many-to-many relationship? At this point, I am not picky about whether the relationship is uni- or bidirectional or about the inheritance strategy.
As an trial, I first converted exercise 7.1 from the workbook in the Burke & Monson-Haefel book, so that the entities run in a container. Client1 exercises a one-to-one unidirectional relationship between Customer and Address; Client2, a one-to-many unidirectional relationship between Customer and Phone. The Admin stateless session EJB includes createCustomer(), findCustomer(), and updateCustomer() methods implemented in the obvious way. In either case, a detached instance of the Customer class is created, a field (address or list of phone numbers) is added to it while detached, and then admin.update() called to do a merge. The new Client1 and Client2 produce the correct results after the conversion.
Then I created a "Base" entity and made Customer extend Base using the JOINED strategy. Base contains an id field, with a getId() method annotated with "Id" and also setId(). I eliminated the id field from the Customer class. This breaks both Client1 and Client2 in the sense that the Address and the Collection member variables in the Customer object remain null after the merge performed by updateCustomer() in Admin. This is true even within the updateCustomer method/transaction itself, so it does not help to set the fetch type to EAGER or to traverse the fields within the transaction explicitly.
I have so far been unable to find a working example of this common pattern, which is key to what I need to do. Suggestions?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3958289#3958289
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3958289
19 years, 9 months