persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="three">
<class>three.Address</class>
<class>three.Man</class>
<properties>
<property name="hibernate.connection.username" value="shiva"/>
<property name="hibernate.connection.password" value="shiva"/>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:xe"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
</properties>
</persistence-unit>
</persistence>
main class
public class OneToOne {
public static void main(
String[] args) {
Persistence persistence=new Persistence();
EntityManagerFactory entityManagerFactory=persistence.createEntityManagerFactory("three");
EntityManager entityManager=entityManagerFactory.createEntityManager();
Man man=entityManager.find(Man.class,222L);
/*Address address =entityManager.find(Address.class,222L);*/
Address address=man.getAddress();
/*Man man=address.getMan(); */
System.out.println("asid:=>"+man.getAsid());
System.out.println("ajob:=>"+man.getAjob());
System.out.println();
System.out.println("aid:=>"+address.getAid());
System.out.println("city:=>"+address.getCity());
System.out.println("name:=>"+address.getName());
System.out.println("fname:=>"+address.getFname());
System.out.println("contry:=>"+address.getContry());
}
}
so i want to connect a one to one realation table names like man, address
but it gives the below error so please help me
Sep 11, 2014 12:21:50 PM org.hibernate.ejb.HibernatePersistence logDeprecation
WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
Sep 11, 2014 12:21:50 PM org.hibernate.ejb.HibernatePersistence logDeprecation
WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
Sep 11, 2014 12:21:50 PM org.hibernate.ejb.HibernatePersistence logDeprecation
WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
Sep 11, 2014 12:21:50 PM org.hibernate.jpa.boot.internal.PersistenceXmlParser doResolve
INFO: HHH000318: Could not find any META-INF/persistence.xml file in the classpath
Sep 11, 2014 12:21:50 PM org.hibernate.jpa.boot.internal.PersistenceXmlParser doResolve
INFO: HHH000318: Could not find any META-INF/persistence.xml file in the classpath
Exception in
thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named three
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at OneToOne.main(OneToOne.java:17)