Results 1 to 15 of 15
Like Tree2Likes
  • 1 Post By SurfMan
  • 1 Post By gimbal2

Thread: Jpa with Hibernate using eclipse

  1. #1
    rithish is offline Member
    Join Date
    Apr 2011
    Posts
    39
    Rep Power
    0

    Default Jpa with Hibernate using eclipse

    Hello iam trying to implement jpa using hibernate in eclipse kepler
    here is my entity class
    Java Code:
    package com.jpa;
    
    import java.io.Serializable;
    import javax.persistence.*;
    
    /**
     * Entity implementation class for Entity: jpaexample
     *
     */
    @Entity
    
    public class jpaexample {
    	@Id
    	@GeneratedValue(strategy = GenerationType.IDENTITY)
    	 private Long id;
    	private String summary;
    	public String getSummary() {
    		return summary;
    	}
    	public void setSummary(String summary) {
    		this.summary = summary;
    	}
    	
    	
    	
       
    }

    And my persisting class
    Java Code:
    package com.jpa;
    
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
    
    public class persistjpa {
    	
    	public static void main(String[] args)
    	{
    		
    		
    		EntityManagerFactory factory=Persistence.createEntityManagerFactory("JpaExamples");
    		EntityManager em = factory.createEntityManager();
    		em.getTransaction().begin();
    		jpaexample f=new jpaexample();
    		f.setSummary("jpa test");
    		em.persist(f);
    	    em.getTransaction().commit();
    
    	    em.close();
    		
    		
    	}
    
    }
    And my persistence.xml file
    Java Code:
    <?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="JpaExamples" transaction-type="RESOURCE_LOCAL">
    	<provider>org.hibernate.ejb.HibernatePersistence</provider>
    		<class>com.jpa.jpaexample</class>
    		<properties>
    			<property name="hibernate.connection.username" value="sa"/>
    			<property name="hibernate.connection.password" value="google"/>
    			<property name="hibernate.connection.url" value="jdbc:sqlserver://localhost:1433;databaseName=rithishdb"/>
    			<property name="hibernate.connection.driver_class" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
    			<property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=rithishdb"/>
    			<property name="javax.persistence.jdbc.user" value="sa"/>
    			<property name="javax.persistence.jdbc.password" value="google"/>
    			<property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
    			<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
    		</properties>
    	</persistence-unit>
    </persistence>

    And the following error i get like this

    Java Code:
    Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named JpaExamples
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    	at com.jpa.persistjpa.main(persistjpa.java:13)
    Last edited by rithish; 07-03-2014 at 02:06 PM.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: Jpa with Hibernate using eclipse

    In other words: the persistence.xml is not in the right place. It needs to be in a META-INF subdirectory on the classpath.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    rithish is offline Member
    Join Date
    Apr 2011
    Posts
    39
    Rep Power
    0

    Default Re: Jpa with Hibernate using eclipse

    Yeah its in META-INF subdirectory

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: Jpa with Hibernate using eclipse

    Apparently not when running this stuff. Perhaps your build path is setup such that XML files are excluded.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    rithish is offline Member
    Join Date
    Apr 2011
    Posts
    39
    Rep Power
    0

    Default Re: Jpa with Hibernate using eclipse

    Ok just give a solution to this problem

  6. #6
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: Jpa with Hibernate using eclipse

    Uh oh.... *Grabs the popcorn*
    gimbal2 likes this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: Jpa with Hibernate using eclipse

    Maybe tomorrow.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    rithish is offline Member
    Join Date
    Apr 2011
    Posts
    39
    Rep Power
    0

    Default Re: Jpa with Hibernate using eclipse

    HII gimbal2 please give a solution for this problem

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: Jpa with Hibernate using eclipse

    I can't give you a solution when you don't make the effort to figure out what the problem is. I was hoping that you would become a little wiser and start looking further into this rather than *demanding* a solution in a forum.

    So far you have completely ignored my previous suggestion, so until you check your build path settings, I am just going to assume the problem is there.

    PS: if your next post is going to contain "how do I check the build path in Eclipse", paste that in Google instead.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  10. #10
    rithish is offline Member
    Join Date
    Apr 2011
    Posts
    39
    Rep Power
    0

    Default Re: Jpa with Hibernate using eclipse

    If i can find a solution then why i should be here and why forums r der???Forums r der to find a solution

  11. #11
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: Jpa with Hibernate using eclipse

    No, forums are there to help reasonable people. So far, you are behaving very unreasonable. You seem to think you can just throw your problem onto the internet and then sit back and wait for an answer. Perhaps you should consider going to work for Burger King instead of becoming a programmer.
    SurfMan likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  12. #12
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: Jpa with Hibernate using eclipse

    (is the popcorn still crispy, SurfDude?)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  13. #13
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: Jpa with Hibernate using eclipse

    Quote Originally Posted by gimbal2 View Post
    (is the popcorn still crispy, SurfDude?)
    It's hot, crispy and I got two buckets in front of me. Do you want the salty or the sweet one?
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  14. #14
    rithish is offline Member
    Join Date
    Apr 2011
    Posts
    39
    Rep Power
    0

    Default Re: Jpa with Hibernate using eclipse

    You were the one saying that you ll say the solution today if u dont know the answer stay away from my posts. Why r u trying to give unnecessary answers its clear that you haven't worked jpa in eclipse.I think you don't know what jpa is.Do u really know what jpa does???You should go to work for burger king

  15. #15
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: Jpa with Hibernate using eclipse

    Bye now, do come again when you've gotten a clue.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Hibernate problem in Eclipse
    By maikki in forum Eclipse
    Replies: 1
    Last Post: 03-19-2010, 12:24 AM
  2. hibernate in eclipse ?
    By khalaf abd allah in forum Eclipse
    Replies: 0
    Last Post: 03-11-2009, 07:34 PM
  3. Hibernate framework with Eclipse
    By banie in forum Web Frameworks
    Replies: 1
    Last Post: 10-28-2008, 02:38 PM
  4. Hibernate with eclipse
    By sundarjothi in forum Eclipse
    Replies: 1
    Last Post: 06-06-2008, 05:24 PM
  5. Problems with hibernate and eclipse
    By Albert in forum JDBC
    Replies: 2
    Last Post: 06-05-2008, 03:34 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •