0 Replies Latest reply: Dec 16, 2009 11:16 PM by 843793 RSS

    Need help with a runtime error using Hibernate in a Java application

      Dear fellow Java developers:

      I am getting a runtime error when I try to run my java application that uses hibernate. The error message I'm getting is:

      org.hibernate.AnnotationException: No identifier specified for entity: com.searchqs.beans.Hadith

      From my research on the web, I've found out that you get this error when you have not set @Id for one of your properties or fields. The thing is, I don't have a primary key in my table, so I'm wondering if it's still necessary to set this value as one of my annotations? If this is so, is there a workaround to this, or must I absolutely have a primary key, which I must map to a field using the @Id annotation? Just wondering. I've attached the class that maps to my table, along with the full stack trace below.

      Thanks in advance to all who reply.
      package com.searchqs.beans; 
      import javax.persistence.Column; 
      import javax.persistence.Entity; 
      import javax.persistence.Table; 
      public class Hadith { 
              String collection; 
              int volume; 
              int bookNumber; 
              String bookTitle; 
              int chapterNumber; 
              String chapterTitle; 
              int hadithNumber; 
              String hadithGrade; 
              String narrator; 
              String matnText; 
              public String getCollection() { 
                      return collection; 
              public void setCollection(String collection) { 
                      this.collection = collection; 
              public int getVolume() { 
                      return volume; 
              public void setVolume(int volume) { 
                      this.volume = volume; 
              public int getBookNumber() { 
                      return bookNumber; 
              public void setBookNumber(int bookNumber) { 
                      this.bookNumber = bookNumber; 
              public String getBookTitle() { 
                      return bookTitle; 
              public void setBookTitle(String bookTitle) { 
                      this.bookTitle = bookTitle; 
              public int getChapterNumber() { 
                      return chapterNumber; 
              public void setChapterNumber(int chapterNumber) { 
                      this.chapterNumber = chapterNumber; 
              public String getChapterTitle() { 
                      return chapterTitle; 
              public void setChapterTitle(String chapterTitle) { 
                      this.chapterTitle = chapterTitle; 
              public int getHadithNumber() { 
                      return hadithNumber; 
              public void setHadithNumber(int hadithNumber) { 
                      this.hadithNumber = hadithNumber; 
              public String getHadithGrade() { 
                      return hadithGrade; 
              public void setHadithGrade(String hadithGrade) { 
                      this.hadithGrade = hadithGrade; 
              public String getNarrator() { 
                      return narrator; 
              public void setNarrator(String narrator) { 
                      this.narrator = narrator; 
              public String getMatnText() { 
                      return matnText; 
              public void setMatnText(String matnText) { 
                      this.matnText = matnText; 
      javax.servlet.ServletException: Servlet execution threw an exception 
      root cause  
      root cause  
      org.hibernate.AnnotationException: No identifier specified for entity: com.searchqs.beans.Hadith