0

I am new to Java and JBoss and JDeveloper. My legacy project has this persistence.xml file:

   <persistence-unit name="DoDSRMGR">
    <jta-data-source>java:/DoDSRDS</jta-data-source>
    <class>dodsr.ManifestsPass1</class>
    <class>dodsr.model.ManifestsPass2</class>
       <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
         <property name="javax.persistence.jtaDataSource" value="java:/DoDSRDS"/>
        </properties>
       </persistence-unit>
   </persistence>

My questions are what do the values in the file mean and what are they for? Also, where does this file belong in the EAR file META-INF or the JAR file META-INF? What is the significance of the name="DoDSRMGR" designation, is this the name of the bean when I call from a Java program or is it the application name? Also what is the "java:/DoDSRDS" do?

Is this the way to call the bean from a desktop application: ( DodsrUserSessionEJB) ctx.lookup("/dodsr/"+ejbName+"/remote");

Dean.DePue
  • 1,013
  • 1
  • 21
  • 45
  • Do you have specific questions or am I to read your mind as to what line you want explained? – hd1 Jun 13 '14 at 16:11
  • @hd1 It would be wonderful if you could read my mind, but, then again, you might get lost in there. Anyway, edited the questions.. – Dean.DePue Jun 13 '14 at 16:12
  • http://docs.oracle.com/javaee/7/tutorial/doc/persistence-intro003.htm – Paul Samsotha Jun 13 '14 at 16:12
  • That file configures a JPA-compliant ORM (in this case Hibernate) - ie your database access. It has no relation to the EJB's. Probably the best thing to do now is to read a bit about the basics of JPA and Hibernate (The Oracle EE tutorial is always a good starting point, as is the Hibernate site. – fvu Jun 13 '14 at 16:39

1 Answers1

1

<persistence-unit name="DoDSRMGR"> This line lets you put a name to a persistence unit. You use the persistent unit name when you want to instantiate an EntityManager in this way:

EntityManager eMgr = Persistence.createEntityManagerFactory("Your persistence unit name").createEntityManager();

An EntityManager is the object that helps you select, persist, update and remove your JPA entities from/into the database.

<jta-data-source>java:/DoDSRDS</jta-data-source> This line tells you how you are going to manage the persistence transactions (persist, update and remove entities). If you don't specify this line, every time you want to persist, update or remove an entity from the database, you have to first get a transaction instance and call begin() after you persist/update/remove your entity and after that you call the commit() method.

Since you already have the jta-data-source element in your XML you don't need to manually call the begin() and commit() methods. Your application server manages the transactionality via a transaction resource identified by the value "java:/DoDSRDS"

This XML file can be placed in either META-INF or WEB-INF folder.

Roberto Linares
  • 2,215
  • 3
  • 23
  • 35
  • thank you! that explains a lot to me, expecially since I am so new to this whole world. I'm going to accept and now I have another question that I'm going to post that I hope you'll take a look at and help me with - it's the error we got when JBoss 7 tried to start the bean file. – Dean.DePue Jun 13 '14 at 16:56