aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate Annotations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Annotations" Watch "Hibernate Annotations" New topic
Author

Hibernate Annotations

eddy johns
Ranch Hand

Joined: Feb 16, 2010
Posts: 67
Hi all,

I'm trying to move my project to Annotations and I've downloaded the latest Hibernate distribution (3.6.0 final). I created a very simple annotated class and I'm trying to add it programmatically by doing this:



This is in the documentation of the release. But I'm getting a compiler (!!!) error: The method addAnnotatedClass(Class<Book>) is undefined for the type Configuration.

When I convert Configuration to AnnotationConfiguration I'm learning that it is deprecated and its functionality was moved to Configuration. So I'm running around in circles here. Just for good measure, here is my Book class:



And my HibernateUtil:



Any ideas? What am I doing wrong? What is the best way to add an annotated class programmatically, or otherwise?

Thanks!
Eddy
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I think if you used the AnnotationConfiguration object, instead of the vanilla Configuration object, you'd be good.



(From This Tutorial)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Annotations