-->
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.  [ 1 post ] 
Author Message
 Post subject: An AnnotationConfiguration instance is required to use<..
PostPosted: Thu Nov 20, 2008 1:12 pm 
Newbie

Joined: Wed Nov 19, 2008 3:57 pm
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.3.1

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="HibernateExample.Color" table="color">

<id name="id">
<generator class="native"/>
</id>
<property name="color"/>

</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
public Main()
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();

session.beginTransaction();

Vector<Color> colors = new Vector<Color>(session.createQuery("from Color").list());

for (Color c : colors)
{
//if (c.getColor().equals("red"))
//{
// c.setColor("redish");
// session.update(c);
//}
System.out.println(c.getId() + " , " + c.getColor());
}

session.getTransaction().commit();

HibernateUtil.getSessionFactory().close();



}

}


Full stack trace of any exception that occurs:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Initial SessionFactory creation failed.org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="HibernateExample/Color"/>
Exception in thread "main" java.lang.ExceptionInInitializerError
at HibernateExample.utils.HibernateUtil.<clinit>(HibernateUtil.java:17)
at HibernateExample.Main.<init>(Main.java:23)
at HibernateExample.Main.main(Main.java:17)
Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="HibernateExample/Color"/>
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1600)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at HibernateExample.utils.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 2 more


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 name="">
<!-- Database connection settings -->
<property name="connection.driver_class">org.firebirdsql.jdbc.FBDriver</property>
<property name="connection.url">jdbc:firebirdsql://localhost/C:/Documents and Settings/James/Application Data/HK-Software/IBExpert/COLORS.fdb</property>
<property name="connection.username">sysdba</property>
<property name="connection.password">masterkey</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="Color.hbm.xml"/>
<mapping class="HibernateExample/Color"/>
</session-factory>
</hibernate-configuration>



Image
Name and version of the database you are using: firebird 2.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


hello I am a noob, Im just trying to get a little demo going for a presentation. Im getting the above errors, saying that I need an annotation to use the mapping? I have a feeling I have just made a simple error. any help would be greatly appreciated.
thank you

Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


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

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.