[hibernate-issues] [Hibernate-JIRA] Created: (HBX-980) org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class=

Matt Braunwart (JIRA) noreply at atlassian.com
Wed Aug 22 16:34:56 EDT 2007


org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class=
------------------------------------------------------------------------------------------------------

                 Key: HBX-980
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-980
             Project: Hibernate Tools
          Issue Type: Bug
          Components: eclipse
    Affects Versions: 3.2beta7
         Environment: Hibernate 3.2 latest, Hibernate Tools 3.2.0, Eclipse 3.3.0
            Reporter: Matt Braunwart


I am having an issue with getting the session factory.  I have searched and searched for anything referring to this, and the results i find are nothing like the error that I am receiving.  If anyone could assist me with this problem, I will be very grateful. 

Problem while executing Create SessionFactory(An AnnotationConfiguration instance is required to use <mapping class="movieblends.beans.Tagsuggestions"/>)

org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="movieblends.beans.Tagsuggestions"/>
An AnnotationConfiguration instance is required to use <mapping class="movieblends.beans.Tagsuggestions"/>
  org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="movieblends.beans.Tagsuggestions"/>
  An AnnotationConfiguration instance is required to use <mapping class="movieblends.beans.Tagsuggestions"/>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 22, 2007 2:31:06 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
    <class name="movieblends.beans.Tagsuggestions" table="tagsuggestions" catalog="mbadmins">
        <comment></comment>
        <id name="messageId" type="int">
            <column name="messageID" />
            <generator class="assigned" />
        </id>
        <many-to-one name="user" class="movieblends.beans.User" fetch="select">
            <column name="userID" not-null="true">
                <comment></comment>
            </column>
        </many-to-one>
        <property name="suggestion" type="string">
            <column name="suggestion" not-null="true">
                <comment></comment>
            </column>
        </property>
    </class>
</hibernate-mapping>

package movieblends.beans;

// Generated Aug 22, 2007 2:31:06 PM by Hibernate Tools 3.2.0.b9

import java.util.List;
import javax.naming.InitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Example;

/**
 * Home object for domain model class Tagsuggestions.
 * @see movieblends.beans.Tagsuggestions
 * @author Hibernate Tools
 */
public class TagsuggestionsHome {

	private static final Log log = LogFactory.getLog(TagsuggestionsHome.class);

	private final SessionFactory sessionFactory = getSessionFactory();

	protected SessionFactory getSessionFactory() {
		try {
			return (SessionFactory) new InitialContext().lookup("SessionFactory");
		} catch (Exception e) {
			log.error("Could not locate SessionFactory in JNDI", e);
			throw new IllegalStateException("Could not locate SessionFactory in JNDI");
		}
	}

	public void persist(Tagsuggestions transientInstance) {
		log.debug("persisting Tagsuggestions instance");
		try {
			sessionFactory.getCurrentSession().persist(transientInstance);
			log.debug("persist successful");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}

	public void attachDirty(Tagsuggestions instance) {
		log.debug("attaching dirty Tagsuggestions instance");
		try {
			sessionFactory.getCurrentSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Tagsuggestions instance) {
		log.debug("attaching clean Tagsuggestions instance");
		try {
			sessionFactory.getCurrentSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void delete(Tagsuggestions persistentInstance) {
		log.debug("deleting Tagsuggestions instance");
		try {
			sessionFactory.getCurrentSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Tagsuggestions merge(Tagsuggestions detachedInstance) {
		log.debug("merging Tagsuggestions instance");
		try {
			Tagsuggestions result = (Tagsuggestions) sessionFactory.getCurrentSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public Tagsuggestions findById(int id) {
		log.debug("getting Tagsuggestions instance with id: " + id);
		try {
			Tagsuggestions instance = (Tagsuggestions) sessionFactory.getCurrentSession().get(
					"movieblends.beans.Tagsuggestions", id);
			if (instance == null) {
				log.debug("get successful, no instance found");
			} else {
				log.debug("get successful, instance found");
			}
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Tagsuggestions instance) {
		log.debug("finding Tagsuggestions instance by example");
		try {
			List results = sessionFactory.getCurrentSession().createCriteria("movieblends.beans.Tagsuggestions").add(
					Example.create(instance)).list();
			log.debug("find by example successful, result size: " + results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}
}

package movieblends.beans;

// Generated Aug 22, 2007 2:31:06 PM by Hibernate Tools 3.2.0.b9

/**
 * Tagsuggestions generated by hbm2java
 */
public class Tagsuggestions implements java.io.Serializable {

	private int messageId;

	private User user;

	private String suggestion;

	public Tagsuggestions() {
	}

	public Tagsuggestions(int messageId, User user, String suggestion) {
		this.messageId = messageId;
		this.user = user;
		this.suggestion = suggestion;
	}

	public int getMessageId() {
		return this.messageId;
	}

	public void setMessageId(int messageId) {
		this.messageId = messageId;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getSuggestion() {
		return this.suggestion;
	}

	public void setSuggestion(String suggestion) {
		this.suggestion = suggestion;
	}

}

<?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="mbdb">
        <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost/mbadmins</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <mapping class="movieblends.beans.Tagsuggestions" />
        <mapping class="movieblends.beans.Review" />
        <mapping class="movieblends.beans.Posts" />
        <mapping class="movieblends.beans.Tags" />
        <mapping class="movieblends.beans.Movie" />
        <mapping class="movieblends.beans.Ratings" />
        <mapping class="movieblends.beans.User" />
        <mapping class="movieblends.beans.Threads" />
        <mapping class="movieblends.beans.Profile" />
    </session-factory>
</hibernate-configuration>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>

<table-filter match-catalog="mbadmins" match-name="keywords"/>
  <table-filter match-catalog="mbadmins" match-name="movie"/>
  <table-filter match-catalog="mbadmins" match-name="posts"/>
  <table-filter match-catalog="mbadmins" match-name="profile"/>
  <table-filter match-catalog="mbadmins" match-name="ratings"/>
  <table-filter match-catalog="mbadmins" match-name="review"/>
  <table-filter match-catalog="mbadmins" match-name="tags"/>
  <table-filter match-catalog="mbadmins" match-name="tagsuggestions"/>
  <table-filter match-catalog="mbadmins" match-name="threads"/>
  <table-filter match-catalog="mbadmins" match-name="user"/>
</hibernate-reverse-engineering>

There is some information on what I have done so far.



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list