[EJB 3.0] - Ejb 3 is DTO less??
by laszlo.fogas
Hi everyone!
I doubt that this question is true. Here is my situation:
I' ve 2 almost the same entities in 2 different table of the database. I generated two entity beans to access them.
An other(object A in the future) entity references one of the former entities in a oneToMany relation.
Sometimes i want access the 2 entities transparently through object A, what i mean is the client does not know which entity it works with, so i generated an Interface for the two entities with the needed methods.
I have one SLSB for accessing object A, and there is a method which ideally return object A but with a Set(PreviouslyDefinedInterface) type for transparent working in the client side.
That's why i changed in the entity the Set type to the interface.
During deploy there is an error that the entity not mapped ...Interface. Which is true, because there's no such entity.
I hope that this was clear :)
So i can't see any option to avoid DTOs now.
Could you give some designing tips?
lazlo
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969417#3969417
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969417
19 years, 7 months
[EJB 3.0] - Question about injecting env-entry into interceptor
by mark.bramnik
Hi
I'm a newbie in the JBOSS world and I've got a problem with env-entry declaration.
I have an ejb-jar.xml with declared interceptor for EJB3 SLSB.
I'm trying to inject the environment entry into the interceptor, and it doen't work.
It seems like jboss merely ignores this declaration- interception mechanism works fine but injection doesn't.
When I'm trying to inject the same env-entry declaration into SLSB bean everything works just fine.
As far as I understand xsd allows me to do such an injection into interceptor.
I'm using JBOSS 4.0.4 GA + EJB3-RC8 on Windows 2000 OS.
Any help is highly appreciated
Thanks in advance.
Mark Bramnik
The relevant code looks like this:
ejb-jar.xml
| <?xml version="1.0"?>
| <ejb-jar xmlns="http://http://java.sun.com/xml/ns/javaee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
| http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
| version="3.0">
| <enterprise-beans>
| <session>
| <ejb-name>SampleDataServiceEJB</ejb-name>
| <ejb-class>xxx.LocalDataServiceEJB</ejb-class>
| <env-entry>
| <env-entry-name>maxExceptions</env-entry-name>
| <env-entry-type>java.lang.Integer</env-entry-type>
| <env-entry-value>15</env-entry-value>
| <injection-target>
| <injection-target-class>xxx.SampleDataServiceEJB</injection-target-class>
| <injection-target-name>maxExceptions</injection-target-name>
| </injection-target>
| </env-entry>
| </session>
| </enterprise-beans>
|
| <interceptors>
| <interceptor>
| <interceptor-class>xxx.SampleLoggingContextInterceptor</interceptor-class>
| <around-invoke>
| <method-name>interceptLog</method-name>
| </around-invoke>
| <env-entry>
| <env-entry-name>minExceptions</env-entry-name>
| <env-entry-type>java.lang.Integer</env-entry-type>
| <env-entry-value>10</env-entry-value>
| <injection-target>
| <injection-target-class>xxx.SampleLoggingContextInterceptor</injection-target-class>
| <injection-target-name>minExceptions</injection-target-name>
| </injection-target>
| </env-entry>
| </interceptor>
| </interceptors>
|
|
| <assembly-descriptor>
| <interceptor-binding>
| <ejb-name>*</ejb-name>
| <interceptor-class>xxx.SampleLoggingContextInterceptor</interceptor-class>
| </interceptor-binding>
| </assembly-descriptor>
| </ejb-jar>
|
SLSB:
package xxx;
|
| import javax.ejb.Stateless;
| import javax.ejb.Local;
| import javax.annotation.Resource;
|
| @Stateless
| @Local(SampleDataService.class)
| public class SampleDataServiceEJB implements SampleDataService {
| @Resource(name="maxExceptions")
| private int maxExceptions;
|
| public int getMaxExceptions() {
| return maxExceptions;
| }
|
| public void setMaxExceptions(int maxExceptions) {
| this.maxExceptions = maxExceptions;
| }
|
| public void sampleExecutionMethod() {
| //......
| }
|
| }
|
The Interceptor
package xxx;
|
| import javax.annotation.Resource;
| import javax.interceptor.InvocationContext;
|
| public class SampleLoggingContextInterceptor {
| @Resource(name="minExceptions")
| private int minExceptions = 1;
|
| public int getMinExceptions() {
| return minExceptions;
| }
|
| public void setMinExceptions(int minExceptions) {
| this.minExceptions = minExceptions;
| }
|
| public Object interceptLog(InvocationContext inv) throws Exception {
| //......
| }
| }
P.S. I copied the code above manually (not copy-pasted) so it may contain some insignificant syntax mistakes...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969416#3969416
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969416
19 years, 7 months