You have a privilege to create a quiz (QnA) related to this subject and obtain creativity score...
4.4.5. Data Service and JPA/Hibernate frameworks in Maven Project
Even more benefits brings a combination of Data Service with JPA/Hibernate in a Maven project, which we consider below.
Create a new Maven Project in Eclipse: NEW-Maven Project.
Do not skip the archetype selection (no simple project!).
NEXT Select the maven-webapp-project archetype for the project.
NEXT Provide Group ID: com.its
The Group ID should reflect a company/department value.
Provide Artifact ID: 4.4.5.Hibernate
The Artifact ID reflects the project name.
FINISH
A new project with the name 4.4.5.Hibernate appears on the left.
Done! You created a new Maven project with Dynamic Web facilities.
Now, modify (copy/paste) the pom.xml file in the project to include necessary libraries.
Saving the content of the pom.xml file will remove the red spot on the index.jsp file under the webapp directory. The red flag was there because the index.jsp file required the javax.servlet library, which we included in the pom.xml.
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0 com.pt 4.4.5.Hibernate war 0.0.1-SNAPSHOT 4.4.5.Hibernate Maven Webapp http://maven.apache.org junit junit 3.8.1 test
Right mouse click on the project name and select Properties.
Click on the Project Facets and check the JPA box.
As usually, check on this screen a version of Java and correct if necessary.
There must be a red flag/link Further configuration required.
Click on this link to manage the JPA Facet window.
Select the Platform as Hibernate (JPA 2.1. or higher).
JPA Implementation is provided by a set of libraries, which we included in the pom.xml file.
This allows us to select Disable Library Configuration.
Check if you can also provide Connection to a database.
If not now, you can do this later.
Click OK.
On the right side of the Project Facets screen, click on the Runtime tab and select Tomcat or JBoss server runtime.
After finishing configuration of the Project Facets and adding the JPA features, you can see that the project has a red flag. To see the Problem window go to the Window Menu.
Window - Others - Problem.
The problem, which is related to this new project, is absence of the persistence.xml file.
JPA expects this file to be located in the src/main/resources/META-INF directory.
Create this file manually and copy/paste the following:
Assignments: 1. Create a Maven project in Eclipse with the name 4.4.5.Hibernate and follow the description above.
2. Check the following links:
- https://javabrains.io/courses/hibernate_intro/lessons/Introduction-To-Hibernate
- https://www.tutorialspoint.com/hibernate/hibernate_tutorial.pdf
Was it clear so far?
onclick="window.location.href='/BASE/jsp/demo.jsp?checkFlavor=itsp&issueID=335&intro=general&group=aitu&ur=f'">
Right mouse click on the project name and select Properties.
Click on the Project Facets and check the JPA box.
As usually, check on this screen a version of Java and correct if necessary.
There must be a red flag/link Further configuration required.
Click on this link to manage the JPA Facet window.
Select the Platform as Hibernate (JPA 2.1. or higher).
JPA Implementation is provided by a set of libraries, which we included in the pom.xml file.
This allows us to select Disable Library Configuration.
Check if you can also provide Connection to a database.
If not now, you can do this later.
Click OK.
On the right side of the Project Facets screen, click on the Runtime tab and select Tomcat or JBoss server runtime.
After finishing configuration of the Project Facets and adding the JPA features, you can see that the project has a red flag. To see the Problem window go to the Window Menu.
Window - Others - Problem.
The problem, which is related to this new project, is absence of the persistence.xml file.
JPA expects this file to be located in the src/main/resources/META-INF directory.
Create this file manually and copy/paste the following:
Assignments: 1. Create a Maven project in Eclipse with the name 4.4.5.Hibernate and follow the description above.
2. Check the following links:
- https://javabrains.io/courses/hibernate_intro/lessons/Introduction-To-Hibernate
- https://www.tutorialspoint.com/hibernate/hibernate_tutorial.pdf