-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate annotations problems
PostPosted: Tue Mar 08, 2005 7:37 pm 
Beginner
Beginner

Joined: Sat Sep 25, 2004 12:42 am
Posts: 27
Hibernate version:
3.0 rc1
annotations-3.0-alpha3

Mapping documents:
Code:
<!DOCTYPE hibernate-configuration PUBLIC
   "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="hibernate.show_sql">true</property>
      <mapping package="test"/>
      <mapping class="test.Comment"/>
   </session-factory>
</hibernate-configuration>

Code:
/**
* @Entity(access = AccessType.PROPERTY)
* @Table(name="comment")
*/
public class Comment
        implements Serializable {
    /**
     * @return
     * @Id(generate=GeneratorType.SEQUENCE, generator="comment_sequence")
     */
    public Long getCommentId() {
        return this.commentId;
    }
}


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

Full stack trace of any exception that occurs:
2005-03-09 09:58:58,062 [ hibernate.cfg.Environment] INFO - Hibernate 3.0rc1
2005-03-09 09:58:58,062 [ hibernate.cfg.Environment] INFO - hibernate.properties not found
2005-03-09 09:58:58,072 [ hibernate.cfg.Environment] INFO - using CGLIB reflection optimizer
2005-03-09 09:58:58,072 [ hibernate.cfg.Environment] INFO - using JDK 1.4 java.sql.Timestamp handling
2005-03-09 09:58:58,072 [ hibernate.cfg.Configuration] INFO - configuring from url: file:/D:/Development/Projects/min
d/src/webapp/WEB-INF/classes/hibernate.cfg.xml
2005-03-09 09:58:58,182 [te.cfg.AnnotationConfiguration] INFO - Mapping package test
2005-03-09 09:58:58,262 [hibernate.cfg.AnnotationBinder] WARN - Package not found or wo package-info.java: test
2005-03-09 09:58:58,262 [te.cfg.AnnotationConfiguration] INFO - Mapping class using metadata: test.Comment
2005-03-09 09:58:58,272 [te.cfg.AnnotationConfiguration] ERROR - Could not compile the mapping annotations
org.hibernate.AnnotationException: Annotated class should have an @Entity annotation: test.Comment
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:210)
at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClass(AnnotationConfiguration.java:44)
at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(AnnotationConfiguration.java:182)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1353)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1335)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1302)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1245)
...

Name and version of the database you are using:
PostgreSQL 8

The generated SQL (show_sql=true):
na

I've compiled with both -srouce 1.5 and -target 1.5 using maven. Given how simple the instructions on the hibernate annotations page make it sound, I presume I havn't cimpiled with annotations (or something)...

I'm also curious about the message: "Package not found or wo package-info.java: test"...

Does anyone have any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 08, 2005 7:41 pm 
Beginner
Beginner

Joined: Sat Sep 25, 2004 12:42 am
Posts: 27
ahh, don't worry... i was placing the annotations in the javadoc comments (I'm converting from xdoclet)...

it should have been:
Code:
@Entity(access = AccessType.PROPERTY)
@Table(name="comment")
public class Comment
        implements Serializable {
private Long commentId;

@return
@Id(generate=GeneratorType.SEQUENCE, generator="comment_sequence")
    public Long getCommentId() {
        return this.commentId;
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 9:35 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
:-)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.