• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA Pro 2 chapter 3 employeeService

 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I updated the original persistence.xml into:

These values are specified to mySQL and I have a database called myTest.

The original persistence.xml provided is:

This may not be applicable to those who don't use Derby database.
And also, the Employee.java should implement Serializable:


And you may want to follow my file structure in Eclispe. See the diagram below.

Create a folder META-INF  under src and put persistence.xml there.
Include eclispelink.jar, javax.persistence...java and mysql-connector-...java in the classpath.

I hope this help.
fileStructure.JPG
[Thumbnail for fileStructure.JPG]
 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more notes, the persistence.xml should be :

Reference:
http://www.javaxt.com/Tutorials/Glassfish/How_to_set_up_a_Connection_Pool
https://dzone.com/articles/connection-pooling-glassfish-nb
https://computingat40s.wordpress.com/how-to-setup-a-jdbc-connection-in-glassfish/
 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we don't specify <jta-data-source>, we cannot use @PersistenceContext(unitName="EmployeeService") in the EmployeeService.java.

If we don't have <jta-data-source>, we should do this:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic