Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No persistence unit with name 'product' found"

I recently completed this tutorial: "http://static.springsource.org/docs/Spring-MVC-step-by-step/", but now I want it to work with Hibernate and annotations. I know I'm close but I've hit a roadblock and I can't figure it out. I've posted my code on the Spring forums here. I would greatly appreciate ANY help. Thanks

I'm trying to incorporate annotations and hibernate into it, but I've run into a problem and I can't figure it out. I keep getting errors of "No persistence unit with name 'product' found". ANY help would be greatly appreciated.

like image 534
type7 Avatar asked Jan 06 '11 07:01

type7


2 Answers

You need a META-INF/persistence.xml, with <persistence-unit name="product">. See here

(I usually put it in WEB-INF/classes/META-INF. As noted in the comments, with maven you can place it in src/main/resources/META-INF)

like image 66
Bozho Avatar answered Oct 05 '22 21:10

Bozho


this is a example of file persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
         version="2.0">
<persistence-unit name="poduct"  transaction-type="RESOURCE_LOCAL">
</persistence-unit>
</persistence>

create this file inside "src/main/resources/META-INF" if you use Maven project.

like image 22
BERGUIGA Mohamed Amine Avatar answered Oct 05 '22 23:10

BERGUIGA Mohamed Amine