on 03-19-2008 6:06 PM
Hi
How can i get EntityManagerFactory jndi name in the NW CE 7.1.
I cant find it on jndi browser tab in the SAP NetWeaver Administrator.
My persistence.xml contains the following entries
<persistence-unit name="test1" transaction-type="JTA">
<jta-data-source>testDataSource</jta-data-source>
<class>test.TestEntity</class>
<jta-data-source>
<persistence-unit>
how should i reffer to it in my java code:
(EntityManagerFactory) context.lookup("????")
My class is not a container managed object so annotation @Persistence want work in that case, so i guess the only way to get EntityManagerFactory is through jndi lookup.
right?
Br
PF
Hi, PaFaWa,
To obtain a container-managed EM instance, you use the @PersistenceContext annotation to have the EJB container inject an EM instance into the application component using dependency injection.
To obtain an application-managed EM instance, you must first obtain an entity manager factory instance.
Please, have a look at [THIS|http://help.sap.com/saphelp_nwce10/helpdata/en/45/0029b3515224dee10000000a114a6b/frameset.htm] link for more information.
Hope that helps!
Regards,
Yordan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Why don't you try using the EJB lookup scheme. There is more information in this article: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b0d58c0a-b2ce-2a10-8082-a3dda343...
Best regards,
Ekaterina
Hi
Thx - the idea sounds very interesting, but applied to this problem seems like forcing opened doors.
I think that all i need is to find Enity|managerFactory jndi name which must be somewhere there in the jndi naming tree.
Perhaps an extra property in the persistence.xml file is needed to set it , like it's done in jboss.
Br
PF
>
> To be more precise, i think it all comes to finding a way to bind EntityManagerFactory into a EJB's naming context.
>
You're right. For that you have to define a reference to the EMF - either via annotation or in the ejb-jar.xml. For example:
@Stateless
@PersistenceUnit(name = "persistence/myLookupName", unitName = "test1")
public class MySessionBean ...
Then you can use JNDI lookup in each and every POJO class that executes on behalf of the MySessionBean component.
HTH!
\-- Vladimir
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.