EJB questions
How do I get the type of a PsiClass: Entity Bean, SLSB, SFSB, or neither of it
Currently I check for annotations which obviously is incomplete, as even in EJB3 beans may be defined in deployment descriptor.
A tougher question:
How do I check if a given interface is the local interface for a session bean?
In EJB3 the interface may not have any annotations at all (when the session bean is annotated with @Local(MyLocalInterface.class).
Please sign in to leave a comment.
Probably EjbHelper.getEjbRole() is what you need?
"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:4333350.1158834931513.JavaMail.itn@is.intellij.net...
>
Thanks Peter, but for Entity beans this returns null and I don't see how I can distinguish between stateless and stateful session beans.
Any idea?
It's not that important, because it turned out that to use Seam on Session beans you need to use @Stateless/@Statefull annotations anyway.
The second part (getting the implementation from the local interface) works fine with your solution.
It shouldn't return null for PsiClass'es that are parts of an EJB. If it
does, then it's a bug, and I'd be grateful for reproduce steps.
When you get a EjbClassRole, you can get EnterpriseBean from it. And if it's
an instance of com.intellij.javaee.model.common.ejb.SessionBean, you may ask
it for isStateful() method, and get what you want.
"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:13712648.1158854560282.JavaMail.itn@is.intellij.net...
>
Here's the simplest project I could think of.
When my inspection runs on build 5734 and I ask for the ejbRole of class com.acme.foobar.User I get null.
Attachment(s):
ejbRoleTest.zip
Oh, yes, I see. @Entity annotation means not Entity EJB, but Java EE
Persistence Entity, it's quite different and new thing. There are roles for
it, too, but they're obtained in a different way, from class
JavaeePersistenceRoleHolder.
"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:23474705.1158856678192.JavaMail.itn@is.intellij.net...
Thanks a lot. Sorry for the confusion - I only ever entered the Java EE domain after EJB 3 was out so I am very easy to confuse...
But then again JBoss Seam documentation and examples always talk about entity beans and always only use @Entity annotation.
Maybe I can then point out another bug here: In the simple mini exmaple I tried to add a persistence.xml descriptor (in the module settings). After that I saw the persistence.xml file in the project tree, but when I double clicked to open it, it vanished from the tree?!
Should it work if I remove the @Entity from Use class and use this descriptor instead:
com.acme.foobar.User ]]>
Currently Idea no longer recognizes the User class as Persistence Entity after that.
Strange. We'll look at it. Is "project tree" Project View or Java EE view?
>
It shouldn't work, because the spec (xsd) says:
Class to scan for annotations. It should be annotated with either @Entity, @Embeddable or @MappedSuperclass. You can remove the annotation, if you create a mapping file ( root tag), reference it in persistence.xml ( tag), and mention your class as Entity class (]]> tag).
Thanks for your patience and answering all those EE newbie questions.
"project tree".
Just checked again. The bug is easy to reproduce:
- Open the mini project I posted
- Open the "Project" tree view
- Expand the META-INF folder
- Open the settings for the module, tab "Ejb Module Settings"
- Click "Add" and "persistence.xml"
- Idea preselects the META-INF folder, click ok
- Note that the project tree view shows the persistence.xml file
- Double click
Hm. If I create both persistence.xml and orm.xml in the same step the double clicking on persistence.xml works, but the orm.xml vanishes...
http://www.jetbrains.net/jira/browse/IDEADEV-9985
"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:10802837.1158916654790.JavaMail.itn@is.intellij.net...