-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Hibernate complains about missing Entity annotation
PostPosted: Sat Oct 29, 2005 2:37 pm 
Beginner
Beginner

Joined: Thu Sep 01, 2005 10:09 am
Posts: 39
II upgraded today to the latest versions of hibernate & annotations. This code worked with 3.1beta3 but now it complains about a missing @Enitity annotation that is already there. Any ideas. Is it because I have rc2 ?

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1rc2 annotations beta6

Mapping documents:
package eiswind.paris.model;

import javax.persistence.Entity;
import javax.persistence.GeneratorType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.Where;
import org.hibernate.validator.Length;

@Entity
@Where(clause="valid = "+BaseEntity.TRUE)
@NamedQuery(name = "Category.list", queryString = "select c from Category c where c.categoryGroup.systemId = :systemId")
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = {"categoryGroup_id", "name","validUntil" }) })
public class Category extends BaseEntity {

....

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Caused by: org.hibernate.AnnotationException: Annotated class should have a @javax.persistence.Entity, @javax.persistence.Embeddable or @javax.persistence.EmbeddedSuperclass annotation: eiswind.paris.model.Category
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:334)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:256)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:191)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:638)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:94)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:62)
at eiswind.paris.application.HibernateUtil$1.run(HibernateUtil.java:44)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)


Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 6:39 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This should work, are you sure, you're using @javax.persistence.Entity and not the org.hibernate.annotations one?

_________________
Emmanuel


Top
 Profile  
 
 Post subject: I do
PostPosted: Wed Nov 02, 2005 1:09 pm 
Beginner
Beginner

Joined: Thu Sep 01, 2005 10:09 am
Posts: 39
As you can see from the imports, it's javax...Entity. I don't know what the heck is wrong with this, as I told you it worked before


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 1:37 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You'll need to play with the debugger, I don't know what's going on

_________________
Emmanuel


Top
 Profile  
 
 Post subject: I'm having the same problem. I have no idea why.
PostPosted: Wed Nov 02, 2005 5:01 pm 
Newbie

Joined: Tue Sep 20, 2005 3:51 pm
Posts: 18
Location: Boston, MA
I had a working application that spontaneously started complaining about missing entity tags. Does anyone have an idea of what steps I should take to troubleshoot this issue?

Here's the error:
org.hibernate.AnnotationException: Annotated class should have an @Entity annotation: RemediationType

Here's what I remember:

The application was working fine yesterday. It's been working for 2 months now. I made some minor changes which all seemed to work fine. I restarted the server and everything worked fine. I shut down the server (my workstation) and start it up today and I get this error. I used to map 10 classes in my configuration file and whatever was the first annotated class would appear in the error message (so I'm certain it's nothing to do with my actual class). I suspect it's classloader or hibernate configuration related, but am stumped.

I'd appreciate any help possible with this issue.

Thanks,
Steven

Here's the class:

Code:
import javax.persistence.*;

@Entity
@SequenceGenerator(name="seq0", sequenceName="remediation_types_seq")
@Table(name="remediation_types")
public class RemediationType {
   private int id;
   private String type;
   
   @Id(generate=GeneratorType.SEQUENCE, generator="seq0")
    @Column(name="remediation_type_id")
   public int getId() {
      return id;
   }
   public void setId(int id) {
      this.id = id;
   }

   @Column(name="remediation_type")
   public String getType() {
      return type;
   }
   public void setType(String type) {
      this.type = type;
   }

}


Here's my config:

Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="connection.datasource">java:comp/env/jdbc/StellaAssessment</property>
        <property name="show_sql">false</property>
        <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>

        <mapping class="RemediationType"/>
    </session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject: Update: Issue Resolved.
PostPosted: Thu Nov 03, 2005 4:20 pm 
Newbie

Joined: Tue Sep 20, 2005 3:51 pm
Posts: 18
Location: Boston, MA
It appears my issue was Tomcat/WTP and not hibernate. Eclipse WTP 0.7 failed to synchronize my classes and libraries properly after a major change. I fixed the issue by recreating my eclipse project.

Thanks all!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.