-->
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.  [ 10 posts ] 
Author Message
 Post subject: Hibernate Tools and Hibernate Annotations
PostPosted: Wed Jan 26, 2005 5:17 pm 
Newbie

Joined: Wed Jan 26, 2005 5:08 pm
Posts: 5
Location: Sydney, Australia
Hi,

I am trying to use Hibernate Tools with Hibernate Annotations. Is this supposed to work? If I list annotated classes in hibernate.cfg.xml, I get an MappingException:

An AnnotationConfiguration instance is required to use <mapping clazz="de.mfits.admin.data.Customer"/>

Regards, Mike

Hibernate version:
Hibernate 3.0 beta 2
Hibernate Tools 3.0 alpha 1
Hibernate Annotations 3.0 alpha 2

hibernate.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!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.connection.username">sa</property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.connection.url">jdbc:hsqldb:test</property>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<mapping class="de.mfits.admin.data.Customer"/>
</session-factory>
</hibernate-configuration>

Mapping documents:
none. Mapping Information is specified as EJB3 Annotations

Full stack trace of any exception that occurs:
org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping clazz="de.mfits.admin.data.Customer"/>
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1379)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1341)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1323)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1290)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1252)
at org.hibernate.console.ConsoleConfiguration.buildWith(ConsoleConfiguration.java:151)
at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:128)
at org.hibernate.eclipse.console.actions.BuildSessionFactoryAction.doRun(BuildSessionFactoryAction.java:50)
at org.hibernate.eclipse.console.actions.ConsoleConfigurationBasedAction.run(ConsoleConfigurationBasedAction.java:47)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:555)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:505)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:419)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2803)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2448)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1569)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1540)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:285)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:220)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
at org.eclipse.core.launcher.Main.run(Main.java:710)
at org.eclipse.core.launcher.Main.main(Main.java:694)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 10:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Have you read this document
http://www.hibernate.org/hib_docs/annotations/

Has configuration (and other guides).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 3:46 am 
Newbie

Joined: Wed Jan 26, 2005 5:08 pm
Posts: 5
Location: Sydney, Australia
david wrote:

Yes, of course! How should I use annotations without reading their documentation? It is very clear to me that I need to use an AnnotationConfiguration when using annotated classes. However in this case I do not have control over the class used for configuring Hibernate.

Maybe, I was not clear enough: The exception does not occur in my code, but it occurs when I use the "Hibernate Tools" Eclipse extension after switching to the Hibernate Console Perspective and using the "Create SessionFactory" command.

I suspected that the "Hibernate Tools" code may not be prepared yet for using annotated classes. Please correct me if I am wrong.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 4:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I don't think Hibernate Tools works with annotated classes yet.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 4:20 am 
Newbie

Joined: Wed Jan 26, 2005 5:08 pm
Posts: 5
Location: Sydney, Australia
michael wrote:
I don't think Hibernate Tools works with annotated classes yet.

Thanks, Michael. That's what I suspected. I was just hoping for the opposite, because the Hibernate Tools can create annotations when creating class source code...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 4:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
It doesn't support it yet - we will add it in the future.
Just need to ensure we can get it in without being too much dependent on JDK 1.5 in the eclipse code....

also please note (as per the doc) the annottions generated is very incomplete (read - not working yet). We hope to get an update out at some point that enables proper annotations in the generated code.

Contributions is very welcome ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 18, 2005 9:01 am 
Regular
Regular

Joined: Tue Jan 06, 2004 3:32 pm
Posts: 80
Location: Munich, Germany
Now - several months later - I am running into the same problem, using the latest versions of Hibernate Tools and Eclipse / WTP.

Should it now be possible to use annotated classes in the Hibernate Console?

If yes, how do I configure an AnnotationConfiguration?

Regards,

Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 18, 2005 9:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it is possible in the beta1 release (you can get something from our nightly builds - but it is not the final version yet)

you just select the checkbox for using annotations in the hibernate console configuration wizard.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 2:35 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:47 pm
Posts: 44
It's unclear to me if it is possible to use this feature using persistence.xml... i.e. automatically detected entity classes. This tool seems to require a hibernate configuration file with all of the classes listed...

Is there anyway to handle schemas with (nearly) pure EJB3 auto-class-detection?

Ryan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 3:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
not yet

_________________
Max
Don't forget to rate


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