[EJB 3.0] - Re: Simplest possible stateless bean
by wolfc
"Renen" wrote : I must say, this is a bit frustrating. I don't understand why I need to generate an interface class. It doesn't seem to add any value to what I am doing, and the interface and the actual bean will always correspond 100%. Silly. I presume that there is an xdoclet type solution that will generate it for me. But I must say, I had hoped to be moving away from that overhead.
How would you like to reference your bean from a client (or servlet)? Maybe there is an alternative that's missing.
"Renen" wrote : Then, including the ear name in the default JNDI name doesn't make sense. What happens if you need to use the classes in multiple ears?
The name for the bean must be as unique as possible in JNDI, or else you wouldn't be able to deploy the same bean in another enterprise application.
For example, you could run multiple shops on the same system and thus only have one coded ShoppingCartBean. This EJB is then included into each EAR which wants shopping cart functionality.
"Renen" wrote : ...
| However, I have no idea in which package I can find org.jboss.annotation.ejb.LocalBinding. I would be obliged if you could let me know. Perhaps somebody could add that nugget to the tutorial as well.
jboss-annotations-ejb3.jar
"Renen" wrote : Interestingly, there are a couple of posts that suggest that you can do the T2Bean.class.getName()) thing. For example: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=66845 (see the last post). To my mind, this is much more elegant. That said, I mostly just want a solution... ;-~
Again a JNDI name needs to be unique. And what if you had multiple bussiness interfaces, should we 'polute' JNDI by binding them all?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4086193#4086193
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4086193
18 years, 10 months
[EJB 3.0] - Re: Foreign Key fields not set for child entity
by davetron5000
I am having the exactly same problem, though I found a really lame workaround (see below).
Basically, without exposing the foreign key and managing it myself, I have no way to model OneToMany relationships. This has to be a bug. The O'Reilly EJB3 book explicitly states that the I should not have to manage the keys.
It seems to be a problem at the Hibernate layer, though I couldn't find anything about it on the Hibernate forums.
The Java Persistence layer seems to correctly interpret the annotations and foreign keys, but when Hibernate executes the query, it either omits the foreign key (for unidirectional relationships) or sets it to null (for bi-directional relationships).
Really Lame Workaround
I'm using MySQL and had my foriegn key field set to not null. This is correct for a composite relationships (you don't want instances of the child sitting around without a parent).
By changing my table to allow nulls in the foreign key field, it correctly updates the databse.
It seems that hibernate (or Java Persistence) wants to insert the rows without foreign keys first, and then does updates to the table to provide the foreign keys. That is pretty lame, and seems like a bug, but with all these crazy layers of stuff, I have no idea to whom to report it.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4086189#4086189
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4086189
18 years, 10 months